-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Describe the bug
When you have two agents in sequence, in this case in a LoopAgent, the second agent is often unable to see items stored in the state of the previous agent.
To Reproduce
This has been hard to replicate as a timing issue, but seems to be OK on smaller prompts, but more noticable on a larger prompt.
e.g
graph_builder1 = LlmAgent(
name="GraphBuilder1",
model=LLM_MODEL1,
generate_content_config=types.GenerateContentConfig(
temperature=0.2
),
instruction=GENERATE_KG_PROMPT.format(knowledge_graph_key="knowledge_graph1"),
tools=[store_knowledge_graph],
output_key='knowledge_graph1',
)
graph_reviewer1 = LlmAgent(
name="GraphReviewer1",
model=LLM_MODEL2,
instruction=REVIEW_PROMPT.format(knowledge_graph_key="knowledge_graph1"),
tools=[validate_turtle, load_knowledge_graph], # <--- can't find key knowledge_graph1
)
kg_refinement_loop1 = LoopAgent(
name="KGRefinementLoop1",
max_iterations=5,
sub_agents=[
graph_builder1,
graph_reviewer1,
StopIfComplete(name="StopChecker1", status_key="graph_status1"),
],
)
from: https://github.com/hammertoe/GraphCycle/blob/main/graphcycle/agent.py#L220C1-L235C2
**Expected

**
A subsequent agent should be able to reliably access state keys from the previous agent
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Darwin Matts-MacBook-Pro-2.local 23.6.0 Darwin Kernel Version 23.6.0: Thu Mar 6 22:01:15 PST 2025; root:xnu-10063.141.1.704.6~1/RELEASE_ARM64_T6000 arm64
- Python version(python -V): Python 3.13.3
- ADK version(pip show google-adk): 1.1.1
Additional context
Like I said, a timing issue... so intermittent. Seems like the second agent is starting before the first has finished saving state or something.