-
Notifications
You must be signed in to change notification settings - Fork 346
Description
Describe the bug
The official Custom Agents documentation example claims that LLM agents can access session state data directly through natural language instructions (e.g., "based on the topic provided in session state with key 'topic'"), but session state is never actually injected into the LLM prompts. The agents work only through conversation context and output_key
mappings, not through direct session state access as documented.
To Reproduce
Steps to reproduce the behavior:
- Copy the StoryFlowAgent example from https://google.github.io/adk-docs/agents/custom-agents/#full-code-example
- Configure ADK to use a local model via LM Studio:
model=LiteLlm( model="openai/qwen3-14b-mlx", # or any other model api_base="http://localhost:1234/v1", )
- In a separate terminal, execute
lms log stream
to begin monitoring raw requests sent to LM Studio - Run the example
- Observe in the log stream that no session state data is included in the actual prompts, only conversation history
Expected behavior
Based on the documentation, I expected one of the following:
- Session state should be automatically injected into LLM prompts when referenced in instructions
- OR the documentation should not reference session state access in agent instructions
Screenshots
Example of actual LLM input from lms log stream
(showing no session state injection):
<|im_start|>system
You are a story critic. Review the story provided in
session state with key 'current_story'. Provide 1-2 sentences of constructive criticism
on how to improve it. Focus on plot or character.
You are an agent. Your internal name is "Critic".<|im_end|>
<|im_start|>user
Generate a story about: a lonely robot finding a friend in a junkyard
For context:
[StoryGenerator] said:
In the sun-scorched desert junkyard, a rusted robot named Echo scoured debris for parts...
<|im_end|>
Notice that:
- The instruction references "session state with key 'current_story'"
- But no actual session state data is present in the prompt
- Only conversation history ("For context: [StoryGenerator] said:...") is provided
Versions
- OS: macOS
- ADK version: 1.5.0
- Python version: 3.12.9
Additional context
This issue affects the core Custom Agents documentation and potentially misleads developers about ADK capabilities. The example works in practice because:
- LLMs infer required data from conversation context (previous agent outputs)
output_key
parameters handle state persistence programmatically- The session state references in instructions are essentially ignored
Impact:
- Developers may expect session state injection functionality that doesn't exist
- The documentation example suggests features not implemented in the current ADK version
- Could lead to confusion about how multi-agent communication actually works in ADK
Suggested fixes:
- Implement actual session state injection to match the documentation, OR
- Update the documentation to remove session state references and explain the actual communication mechanism (conversation context + output_key)
Related documentation:
- https://google.github.io/adk-docs/agents/custom-agents/#full-code-example
- The StoryFlowAgent example specifically shows this pattern in all agent instructions