Skip to content

fix: check every function response, not just the first, when resolving which agent to resume - #810

Open
prasanna8585 wants to merge 1 commit into
google:mainfrom
prasanna8585:fix/resolve-resumption-agent-from-every-function-response
Open

fix: check every function response, not just the first, when resolving which agent to resume#810
prasanna8585 wants to merge 1 commit into
google:mainfrom
prasanna8585:fix/resolve-resumption-agent-from-every-function-response

Conversation

@prasanna8585

@prasanna8585 prasanna8585 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

fix in google/adk-python (commit 5449314) while auditing a routine commit batch -- adk-python's Runner._resolve_invocation_id had the identical gap in the Python port of this same resumption logic.

findMatchingFunctionCall resolved which agent to resume after a tool/LRO boundary using only functionResponses[0].id from the last session event. A single event can carry responses answering calls from different agents at once (e.g. two long-running operations from sibling sub-agents completing together and being resumed in one message). Resolving from only the first response silently attributed the rest to whichever agent's call happened to come first.

Dynamically confirmed before fixing with a PoC: two sibling agents each raising their own long-running call, resumed together in one event, resolved to only the first agent -- completely silent that the second response belonged to a different agent.

Fix mirrors adk-python's exact fail-closed philosophy: every response in the last event is checked, and if they resolve to calls from more than one distinct agent, the function throws rather than picking one.

Verified: all 53 pre-existing tests pass unmodified, plus 2 new tests (55 total). Broader core/test/runner/ suite (6 files, 152 tests) passes with no regressions. tsc --noEmit, eslint, prettier --check all clean. Dynamically confirmed by reverting the fix in isolation and reproducing the exact silent-misattribution PoC before restoring.

…g which agent to resume

Independent finding, not a response to review feedback. Found via a
same-day sibling fix in google/adk-python (fix: check every function
response, not just the first, when inferring which invocation to
resume, commit 5449314) while auditing a routine commit batch --
adk-python's Runner._resolve_invocation_id had the identical gap in
the Python port of this same resumption logic.

findMatchingFunctionCall resolved which agent to resume after a
tool/LRO boundary using only functionResponses[0].id from the last
session event. A single event can carry responses answering calls
from different agents at once -- for example two long-running
operations from sibling sub-agents completing together and being
resumed in one message. Resolving from only the first response
silently attributed the rest to whichever agent's call happened to
come first: that response would then be processed under a resumed
agent's context it was never meant for, and the agent it actually
answers would never be correctly resumed at all.

Dynamically confirmed before fixing: a PoC with two sibling agents
(agent_a, agent_b) each raising their own long-running call, resumed
together in a single event, resolved to agent_a via
determineAgentForResumption -- completely silent about agent_b's
response belonging to a different agent entirely.

Fix mirrors adk-python's exact fail-closed philosophy, adapted to
this function's own return type (an Event, not a bare invocation id):
every function response in the last event is now checked, and when
the responses present resolve to calls authored by more than one
distinct agent, the function throws rather than picking one --
determineAgentForResumption's only caller can resume a single agent,
so an event answering calls from two different agents at once has no
single correct answer to fail open with.

Dynamically confirmed the fix closes the gap: reverted it in
isolation, rebuilt, and reproduced the exact silent-misattribution PoC
before restoring and confirming it now throws with a message
identifying both conflicting agents.

Dedup checked before building: no existing GitHub issue, PR, or
commit in this repo addresses this specific multi-response
resumption-ambiguity pattern.

Verified: all 53 pre-existing tests in functions_test.ts pass
unmodified against the patched source (no regression), plus 2 new
tests (55 total). Broader core/test/runner/ suite (6 files, 152
tests, covering determineAgentForResumption's actual callers) passes
with no regressions. tsc --noEmit, eslint, and prettier --check all
clean.
@Varun-S10

Copy link
Copy Markdown
Contributor

Hi @kalenkevich, I have checked the issue and validated the proposed changes. I was able to reproduce the issue. Could you please review this PR?

@Varun-S10 Varun-S10 added the needs review [Status] The PR/issue is awaiting review from the maintainer label Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants