Parent Agent Session Information Not Passed to AgentTool #3456
Replies: 3 comments
-
|
As I understand, the issue connected with how Agent is tool works internally. It creates their own in memory session manager and session https://github.com/google/adk-python/blob/main/src/google/adk/tools/agent_tool.py#L137 So, fundamentally agent as a tool is not the same as delegating flow of execution to sub_agent, it's just the way to "mimic" tool using Agent. Also I think another side-effect of this that we need to declare args of Agent as a a tool (e.g. with input_schema of Agent) to understand how we should call Agent as a tool properly from main flow. Maybe I wrong, ready to hear clarification how we should use Agent as a tool properly :) |
Beta Was this translation helpful? Give feedback.
-
|
Hi @jobmthomas12 , I believe the calling agent, not the AgentTool, should be responsible for managing the conversation history. Passing the full history could include a lot of irrelevant information. Instead, the calling agent should pass only the necessary context. This approach leads to the following workflow, which I find acceptable: The root agent delegates a task to the AgentTool. |
Beta Was this translation helpful? Give feedback.
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The behavior you are observing is expected. When an agent is wrapped as an Hi @jobmthomas12, Thank you for the detailed question and for providing the code snippet. Your analysis is correct, and this is indeed the intended behavior in the ADK framework. Here’s a breakdown of why this happens:
Your suggestion to clarify this in the documentation is excellent. The distinction between these two multi-agent patterns is a crucial concept, and making it more explicit in the "Explicit Invocation - AgentTool" section would be very helpful for the community. We appreciate you bringing this up and offering to contribute to the documentation! References |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The root agent is not passing the session to the child agents ( while checking the session id under the invocation context ) when the child agents are used as AgentTools. However, session transfer works correctly when using sub_agents.
Is it expected behaviour to support session transfer in such cases? If not, we should document this in Explicit Invocation - AgentTool.
I'm happy to update the documentation once the expected behaviour is confirmed.
Attached is the complete code for reference
MultiAgentSessionTransfer copy.txt
Code snippet.
The code first prints the Runner session ID:
Later, when we ask a question like “What is the price of BMW X1?”, it triggers the tool_callback_cars. Inside this callback, I print the session ID from the invocation context.
Expected response
Beta Was this translation helpful? Give feedback.
All reactions