Skip to content

fix: yield tool responses before confirmations#765

Open
gustafvh wants to merge 1 commit into
google:mainfrom
freda-ab:fix/function-responses-before-confirmation
Open

fix: yield tool responses before confirmations#765
gustafvh wants to merge 1 commit into
google:mainfrom
freda-ab:fix/function-responses-before-confirmation

Conversation

@gustafvh
Copy link
Copy Markdown

Link to Issue or Description of Change

Problem

runOneStep currently yields a generated adk_request_confirmation event before yielding the merged function-response event from tool execution.

Consumers commonly pause as soon as they receive a tool confirmation request so they can ask a user to approve or reject the pending action. If such a consumer stops iterating at that boundary, the confirmation request is yielded and persisted, but the already completed function-response event may never be persisted to session history.

Solution

Yield the merged function-response event before yielding the generated adk_request_confirmation event, so completed tool results are persisted before execution pauses for human confirmation.

Testing Plan

  • Added TestToolConfirmationYieldsFunctionResponseBeforeConfirmation verifying a consumer that stops at the confirmation event has already seen the tool function response.
  • Updated TestToolConfirmation fixture order for the new yield order.
  • Updated TestMCPToolSetConfirmation fixture order for the new yield order.
  • Ran focused unit tests locally.
go test ./internal/llminternal ./tool/functiontool ./tool/mcptoolset

Alignment with adk-python

This keeps the session-history invariant that completed tool responses are available before the framework pauses for human approval of a confirmation request.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 modifies the tool execution flow in base_flow.go to yield function responses before confirmation requests. This change ensures that tool results are persisted by consumers even when execution pauses for user approval. The test suites in function_test.go and set_test.go have been updated to reflect this new event ordering, and a new test case was added to specifically verify the sequence. I have no feedback to provide as there were no review comments.

@radhus
Copy link
Copy Markdown

radhus commented Apr 28, 2026

@mazas-google tagging you here

A consumer that pauses on receiving an adk_request_confirmation event
(typically to await human approval) would never see the merged
function-response event for tools that already executed in the same
step. Yield completed responses first so they are persisted before the
human-confirmation pause.

Fixes google#759
@radhus radhus force-pushed the fix/function-responses-before-confirmation branch from 80e2dcd to b087891 Compare May 4, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function responses may not be persisted before tool confirmation pauses execution

2 participants