Skip to content

Fix: Deep-copy session for single_turn and explicitly set branch on injected user events (issue #5686)#5768

Closed
9chait9 wants to merge 1 commit into
google:mainfrom
9chait9:fix/issue-5686-s3c7d1
Closed

Fix: Deep-copy session for single_turn and explicitly set branch on injected user events (issue #5686)#5768
9chait9 wants to merge 1 commit into
google:mainfrom
9chait9:fix/issue-5686-s3c7d1

Conversation

@9chait9
Copy link
Copy Markdown

@9chait9 9chait9 commented May 20, 2026

Fixes #5686

This PR addresses an issue where sequential calls to ctx.run_node() with single_turn agents fail to receive their node_input. The fix involves:

  1. Deep-copying the session and clearing events: In prepare_llm_agent_context, the session copy is changed from shallow to deep, and the session.events list is explicitly cleared for single_turn agents. This ensures each single_turn agent starts with an isolated and clean event history.
  2. Explicitly setting branch for injected user events: In prepare_llm_agent_input, the user_event.branch is explicitly set to ctx._invocation_context.branch. This ensures the node_input is correctly scoped to the child agent's branch, preventing it from being filtered out by _is_event_belongs_to_branch.

…njected user events to correctly scope node_input in sequential ctx.run_node calls (issue google#5686)
@9chait9 9chait9 marked this pull request as ready for review May 20, 2026 16:08
@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label May 20, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented May 20, 2026

Response from ADK Triaging Agent

Hello @9chait9, thank you for submitting this PR to fix #5686!

To help our reviewers process this change more efficiently, please ensure the following sections from our contribution guidelines are addressed:

  1. Testing Plan: Please include a testing plan section in your PR description outlining how the changes are tested.
  2. Unit Tests: Since this is a core bug fix, please add or update unit tests under tests/unittests/ to cover these scenarios and prevent future regressions, and include a summary of passed pytest results.
  3. Logs / Screenshots: Please provide verification logs or console outputs showcasing that sequential ctx.run_node calls now succeed as expected.

Thank you for your valuable contribution!

@rohityan rohityan self-assigned this May 20, 2026
@rohityan rohityan closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ctx.run_node() sequential calls to multiple single_turn agents — second agent receives empty/ignored node_input

3 participants