Skip to content

Loop agent overwrites state's output key when invoking exit_loop tool #1403

@hazrmard

Description

@hazrmard

Describe the bug

This is a bug in the LoopAgents demo. The demo shows an iterative writing pipeline.

  1. An initial writer agent produces an output and assigns it to a state key CURRENT_DOC.
  2. LoopAgent
    a. A LLMAgent writes feedback and outputs it to another state key. If no feedback, it outputs COMPLETION_PHRASE
    b. A LLMAgent uses that feedback to re-write the document, outputting it to the same state key CURRENT_DOC. If COMPLETION_PHRASE is present in feedback, it doesnt output anything and calls exit_loop tool.

To Reproduce

Steps to reproduce the behavior:

  1. Copy/run LoopAgents demo in adk ui (adk web --log_level DEBUG --port 8000 path/to/agent/dir
  2. Run the agent with some topic.
  3. Observe that there is no final output. Observe that state[current_document] is now an empty string when the invocation ends.

Expected behavior

The last unmodified state value is propagated through the end of the loop. This seems to be the intent of the demo, but it doesn't work.

Screenshots

The state variable during intermediate events in the agent invocation:

Image

The final state is empty:

Image

Versions

  • OS: Linux
  • ADK version: 1.25.1
  • Python version: 3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions