-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Pass parent session ID to child sessions in AgentTool #3952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Pass parent session ID to child sessions in AgentTool #3952
Conversation
Summary of ChangesHello @mattmcc-attest, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical issue in the AgentTool where child sessions were not inheriting the session ID from their parent agents. By explicitly passing the parent session ID during child session creation, this change ensures seamless session continuity across nested agent interactions, significantly improving the accuracy of debugging, tracking, and metric collection within the ADK framework. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses the issue of propagating the parent session ID to child sessions created by AgentTool. The change is simple and effective. The new unit test, test_agent_tool_passes_parent_session_id, thoroughly validates this behavior. My main feedback is on the test file, where there is significant code duplication between the new test and an existing one. I've suggested refactoring this into a shared pytest fixture to improve maintainability.
5dc8cf5 to
8d99592
Compare
df838a5 to
3af6a91
Compare
|
Hi @mattmcc-attest , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
|
Hi @seanzhou1023 , can you please review this. |
When AgentTool creates a child session for a sub-agent, it now passes the parent session ID to maintain session continuity across agent boundaries. This ensures that child agents can properly track and reference their parent session context. Changes: - Added session_id parameter to create_session call in agent_tool.py - Added test_agent_tool_passes_parent_session_id to verify the behavior Testing: - All 16 unit tests pass - New test specifically validates session ID propagation
3af6a91 to
48d5b0a
Compare
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
New session IDs were being generated when calling agent tools causing issues debugging and with tracking (emitting metrics etc). This issue was specifically seen when adding plugins to a parent agent. When the agent tool was called and the plugin checked the session ID - it was not the same as the parents.
Solution:
When AgentTool creates a child session for a sub-agent, it now passes the parent session ID to maintain session continuity across agent boundaries. This ensures that child agents can properly track and reference their parent session context.
Changes:
Testing Plan
Testing:
Unit Tests:
===================== test session starts ====================== collected 16 items tests/unittests/tools/test_agent_tool.py::test_agent_tool_passes_parent_session_id PASSED ... ================ 16 passed, 25 warnings in 1.67s ================
Manual End-to-End (E2E) Tests:
You can
uv buildand point your sample application to the locally built version of ADK. If you add a plugin or a callback you should see the before/after:Checklist