Repository navigation
AgentTool: option to propagate parent conversation history to child session #6019
Description
🔴 Required Information
Is your feature request related to a specific problem?
The problem is the following: AgentTool starts the child agent with a blank session. The child only sees args["request"], which is a string generated by the parent LLM and, therefore, that is rephrased. This means the following:
- The child has no idea what the user actually said in prior turns.
- Emphasis and constraints can get lost in the parent's rephrasing (For example, imagine the user said something like "MUST have 2 bedrooms, won't compromise" can become "find apartment with 2 bedrooms").
- This also impact LLM-oriented Confirmation flows and multi-turn extraction tasks, because the child can't reference earlier messages.
Today the only workaround is subclassing AgentTool and manually injecting parent events into the child session — multiple people have done this independently (see #3878, where a contributor built a ContextAwareAgentTool and noted "For a long-term solution, we need a new pattern to be established in ADK").
PS: Although sub_agents share conversation context, they have fundamentally different dynamics — a sub-agent takes over the conversation via transfer_to_agent and the parent is out of the loop until control returns. AgentTool is the opposite: the parent calls the child, gets a result, and continues its own reasoning. It's a tool call, not a handoff. These are two distinct interaction patterns, and the tool-call pattern would benefit from optionally having conversation history available without changing its control-flow semantics.
Describe the Solution You'd Like
A new opt-in boolean on AgentTool:
AgentTool(agent=my_agent, propagate_conversation_history=True)When True, user/model text events from the parent session are copied into the child's ephemeral session before execution. Same pattern as the existing propagate_grounding_metadata and include_plugins flags.
Key constraints:
- Defaults to
False— existing behavior unchanged. - Excludes
function_call/function_responseevents (they'd reference tools the child doesn't have). - Creates fresh
Eventobjects (nostate_deltaleakage). - Filters out
thoughtparts.
Impact on your work
We have production agents where a parent routes to specialized tool agents for extraction tasks. Without conversation context, the tool agents consistently misclassify user intent. The subclass workaround works but breaks on ADK upgrades. A first-class parameter would let us remove fragile internal-API dependencies.
Willingness to contribute
Yes — I have a working implementation with tests and will open a PR right away.
🟡 Recommended Information
Describe Alternatives You've Considered
| Alternative | Why it doesn't work |
|---|---|
sub_agents (handoff) |
Transfers full control to the child — parent can never route again. Incompatible with AgentTool's call-and-return contract. |
mode='chat' |
Has unresolved scheduler bugs (#5780), only applies to LlmAgent callers, and changes semantics (multi-turn vs. single-turn with context). |
| Persistent sessions (PR #2849, closed) | Solves a different problem (cross-invocation caching). We only need current-call context injection — no lifecycle or cleanup concerns. |
| Subclass workaround | Brittle — duplicates framework internals, breaks on upstream refactors. |
Proposed API / Implementation
The implementation is ~30 lines of new code, following the propagate_grounding_metadata pattern exactly:
- New kwarg on
AgentTool.__init__and_TaskAgentTool.__init__ - A small
_inject_conversation_historyhelper - A 3-line call site in
run_asyncaftercreate_session
No changes to _SingleTurnAgentTool, AgentToolConfig, or from_config (matching precedent).
Additional Context
Related issues:
- Multi-agent system problems #3878 — community workaround + request for first-class support
- Migration from SequentialAgent to Workflow with AgentTools: Context is lost #5780 — context loss confirmed as known v2 regression
- [live] ChatBot as a tool #3954 — requests persistent conversation for AgentTool
- Parent Agent Session Information Not Passed to AgentTool #2130 — established "isolation by design" (we respect this via opt-in default)
Precedent:
d689a04f—propagate_grounding_metadataaddition777dba30—include_pluginsaddition
Activity
adk-bot commentedon Jun 8, 2026
GitHub Issue #6019 Analysis: AgentTool: option to propagate parent conversation history to child session
Executive Summary
AgentToolruns start wrapped child agents with an entirely blank event history. Consequently, the child agent cannot see the user's prior conversation context/constraints and relies only on the rephrased query parameter (args["request"]or structured schema properties).propagate_grounding_metadataandinclude_pluginsarchitectural patterns. Since it defaults toFalse, standard behavior remains pristine.Detailed Analysis
1. Root Cause Analysis ("What is broken?")
When an
AgentToolis invoked viaAgentTool.run_async, it creates a fresh, isolatedInMemorySessionServicechild session.During this, only the current invocation's query is packaged as a
types.Contentobject and passed asnew_messageto the child'srunner.run_asyncfunction:Because of this design, the child is blinded to user constraints or requirements specified in previous turns of the parent conversation, unless developers subclass
AgentToolto manually extract and transplant events—a workaround that is fragile across ADK upgrades.Proposed Solution Code
A module-level helper in
agent_tool.pycan cleanly filter and inject the history:And wired in
AgentTool.__init__agent_tool.py:L123-136 and_TaskAgentTool.__init__agent_tool.py:L381-396 as:2. Existing Pull Requests ("Is there a linked PR that fixes this issue?")
3. Recommendation
AgentToolparadigms, mimickingpropagate_grounding_metadataand respecting isolation by default.False, there is zero risk of regression.Summary of Work Done
AgentTool.run_asyncand analyzed the parent context's available events.agent_tool.pyand prepared a premium structured report in full compliance with the read-only guidelines.GiulioCMSanto commentedon Jun 8, 2026
Link to the PR: #6020
sanketpatil06 commentedon Jun 9, 2026
Hi @GiulioCMSanto , Thanks for bringing this and taking time to raise a PR. Your request is currently being reviewed, and we will let you know if anything further is needed. We appreciate your contribution.
godwin3737 commentedon Jun 15, 2026
@GiulioCMSanto , @sanketpatil06 To prevent potential token overflow or context-window issues in longer sessions/histories, I've left a few suggestions to introduce an optional "max_history_messages" configuration parameter. This allows users to cap the injected history to the most recent N eligible turns.
I've also appended a unit test to verify the capping logic and parameter forwarding.