Skip to content

refiner_agent overwrites current_plan with completion phrase on successful loop #4

@MMDPY

Description

@MMDPY

File: b3_loop_agent/agents.py

In the iterative planner example, refiner_agent uses output_key="current_plan", which unconditionally writes the agent's text output to state after every run. When the critic approves the plan, the refiner is instructed to echo the completion phrase, which gets written to current_plan, silently overwriting the last valid plan.

As a result, after a successful loop, current_plan holds "The plan is feasible and meets all constraints." rather than the actual approved plan (e.g. "Activity: Exploratorium, Restaurant: La Mar").

Suggested fix: Remove output_key from refiner_agent and replace it with a custom tool (e.g. update_plan) that writes to state only when a genuine new plan is produced. When the critique is the completion phrase, the agent skips the tool call entirely, leaving current_plan intact.

Thanks for the great examples!! Hope this helps!
Mohammad Karimi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions