how do agents implicitly use states? #477
Replies: 3 comments 3 replies
|
I don't think it would work, as if you don't refer to the state like |
|
The code in loop agent part of the documentation says it does # Conceptual Example: Using output_key and reading state
from google.adk.agents import LlmAgent, SequentialAgent
agent_A = LlmAgent(name="AgentA", instruction="Find the capital of France.", output_key="capital_city")
agent_B = LlmAgent(name="AgentB", instruction="Tell me about the city stored in state key 'capital_city'.")
pipeline = SequentialAgent(name="CityInfo", sub_agents=[agent_A, agent_B])
# AgentA runs, saves "Paris" to state['capital_city'].
# AgentB runs, its instruction processor reads state['capital_city'] to get "Paris". |
|
You're right @paulrinaldi. {} notation is required. boyangsvl's original skepticism was correct: plain-text mentions of a state key in an instruction don't give the model implicit access, only {variable} templating does. The docs example has since been cleaned up too, the current sequential-agents pipeline example uses proper {generated_code}/{review_comments} templating throughout. See discussion #2489 for the fuller breakdown of how state actually reaches the model. Closing this out since it's answered, feel free to reopen if anything's still unclear. |
Uh oh!
There was an error while loading. Please reload this page.
I have a question and am too lazy to look at the code for that.
Say you have a state like {"first_name": "Alex"} and the query to agent is "What is the first name? You can look at state's first_name key".
q1: Does the agent answer this? Based on my test it does.
q2: How does this happen? There should be somewhere that we put the state values in the prompt/instruction. who does it?
All reactions