Skip to content

feat(tools): add propagate_conversation_history option to AgentTool#6020

Open
GiulioCMSanto wants to merge 1 commit into
google:mainfrom
GiulioCMSanto:feat/propagate-conversation-history
Open

feat(tools): add propagate_conversation_history option to AgentTool#6020
GiulioCMSanto wants to merge 1 commit into
google:mainfrom
GiulioCMSanto:feat/propagate-conversation-history

Conversation

@GiulioCMSanto

Copy link
Copy Markdown

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

New tests added to tests/unittests/tools/test_agent_tool.py:

Test What it verifies
test_propagate_history_injects_user_and_model_events User/model text events from parent session are injected into child
test_propagate_history_excludes_function_call_events Function-call-only events (no text) are skipped
test_propagate_history_creates_events_without_state_delta Injected events have no state_delta (prevents child state corruption)
test_propagate_history_disabled_by_default Default False behavior is unchanged — zero history in child
test_propagate_history_child_sees_context_end_to_end Full e2e: child agent's LLM request includes parent conversation turns
pytest tests/unittests/tools/test_agent_tool.py -v
======================= 39 passed in 1.41s ========================

Manual End-to-End (E2E) Tests:

Tested with a multi-turn conversational agent where a parent routes to a tool agent for filter extraction. Without propagate_conversation_history=True, the child misclassifies user constraints (treats mandatory requirements as soft preferences). With it enabled, the child correctly identifies non-negotiable requirements from the full conversation context.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

Implementation follows the propagate_grounding_metadata pattern exactly:

  • New kwarg propagate_conversation_history: bool = False on AgentTool.__init__
  • A _inject_conversation_history module-level helper (~25 lines)
  • A 3-line call site in run_async after create_session
  • Forwarded through _TaskAgentTool.__init__

Not modified (intentionally):

  • _SingleTurnAgentTool — uses run_node (parent already shares context)
  • AgentToolConfig / from_config — matching precedent (propagate_grounding_metadata didn't wire through config either)

Design decisions:

  • Defaults to False — existing behavior unchanged for all current users.
  • Only user/model text events are injected — function_call/function_response events are excluded because they reference tools that only exist in the parent runner.
  • Fresh Event objects are created — prevents state_delta from original events being replayed in the child session.
  • thought parts are filtered out — internal reasoning shouldn't leak to the child.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jun 8, 2026
@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Response from ADK Triaging Agent

Hello @GiulioCMSanto, thank you for creating this PR! It looks like a great addition to AgentTool.

While you have provided an excellent description of your manual E2E test, to fully align with our contribution guidelines, could you please provide:

  1. The E2E testing setup (e.g., the agent definition and runner setup you used).
  2. The command used and the console output/logs showing the test results, highlighting the sections of the log showing that the conversation history is being successfully propagated.

This information will help reviewers verify and understand the changes more efficiently. Thank you!

@adk-bot

adk-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

I will start by reading the instructions in the adk-pr-analyze skill to understand the process for analyzing pull requests.I will now execute the triage/verification script for PR #6020 to verify the contributor's CLA and fetch the PR metadata. This is the mandatory entry gate.I will fetch the details of PR #6020 using the custom fetch_github_pr tool since terminal command execution was denied.I will view the triage_pr.py script to understand how it performs the CLA check and if we can perform the check or inspect the logic safely.I will fetch the details of the linked issue #6019 to better understand the context and requirements of this PR.I will now retrieve the pull request diff for PR #6020 using the GitHub CLI via run_command to inspect the changes.I will search the repository to find the location of the agent_tool source and test files.I will retrieve the line-by-line diff specifically for src/google/adk/tools/agent_tool.py to inspect the implementation of the feature.I will run the help command for gh pr diff to check the correct syntax for viewing the diff of a specific file.I will fetch the diff for src/google/adk/tools/agent_tool.py by excluding the test file using the --exclude flag.I will retrieve the diff for the tests file by excluding src/google/adk/tools/agent_tool.py so that we have the entire testing surface context.I will search for test_propagate_history_injects_user_and_model_events in the baseline code to see if it is already present or if we are reviewing it from the local workspace files.I will view the baseline code of src/google/adk/tools/agent_tool.py to compare and verify the context of the changes.I will search the repository to see other usages of part.thought to confirm its consistency with ADK's representation of Parts.I will view src/google/adk/tools/tool_context.py to check the attributes and types of ToolContext.I will search for the definition of Context to confirm its workspace integration and attributes like session.I will view src/google/adk/agents/context.py to confirm the presence of the .session attribute on the Context object.I will search context.py for variables or properties related to session.I will search for any mentions of session as an attribute or property within the context.py file to verify its interface.I will perform a line-by-line grep search in context.py to get the matching snippets.I will find session.py to inspect the Session model.I will view src/google/adk/sessions/session.py to confirm the presence of the events property on the Session model.I will fetch the statusCheckRollup of PR #6020 using gh pr view to inspect its status checks, including the Google CLA signature verification.I will view the run_async method of AgentTool in the baseline code to check the context around the insertion point.I will find the location and view the definition of _TaskAgentTool in the baseline code to make sure it is updated correctly in the PR.I will view src/google/adk/tools/agent_tool.py around line 374 to check the _TaskAgentTool constructor interface.I will write the complete, detailed pull request analysis to an artifact file as instructed by the ADK Pull Request Analysis skill workflow.I have conducted a thorough review and analysis of PR #6020. I verified the compliance status and evaluated the implementation against ADK's development and style standards.

The complete and detailed pull request analysis is available in the created artifact:
👉 pr_analysis_report.md


Executive Summary of the PR

  • Title: feat(tools): add propagate_conversation_history option to AgentTool
  • Author: @GiulioCMSanto
  • Contributor CLA: Verified (Status: SUCCESS)
  • Objective: Introduces the propagate_conversation_history: bool = False opt-in parameter to AgentTool and _TaskAgentTool to forward parent conversational turns (excluding thoughts, tool calls, and state deltas) into the child agent's session before execution.
  • Justification & Value: Valuable Feature. Elegant, non-intrusive solution to nested context isolation issue (e.g. AgentTool: option to propagate parent conversation history to child session #6019), preserving ADK's "isolated-by-design" default framework behavior.
  • Alignment with Principles: Pass. Perfect compliance. Follows modern type hints, keyword-only parameter pattern, respects the internal package boundaries, and includes impeccable unit tests.
  • Recommendation: Approve. The changes are clean and ready to compile and merge immediately. No style nits or adjustments are required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AgentTool: option to propagate parent conversation history to child session

2 participants