fix(flows): terminate invocation at tool-level EUC#5638
Open
doughayden wants to merge 1 commit intogoogle:mainfrom
Open
fix(flows): terminate invocation at tool-level EUC#5638doughayden wants to merge 1 commit intogoogle:mainfrom
doughayden wants to merge 1 commit intogoogle:mainfrom
Conversation
- Set end_invocation after auth event in postprocess - Mirrors _resolve_toolset_auth's interrupt signal - Tests assert single LLM call when auth requested - events[-3] -> events[-2] in resume tests (tail trimmed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
This change adds
invocation_context.end_invocation = Trueafter the auth event yield in_postprocess_handle_function_calls_async, mirroring the existing termination signal in_resolve_toolset_auth. Tool-level auth now terminates symmetrically with toolset-level auth at the EUC, instead of continuing for one more LLM call.Testing Plan
Unit Tests:
Three existing tests in
test_functions_request_euc.pyhad assertions tied to the trailing post-EUC LLM call:test_function_request_euc: addsassert len(mock_model.requests) == 1to anchor the new termination behavior.test_function_get_auth_response:events[-3]→events[-2]for the auth event lookup, since the auth event is now second-to-last.test_function_get_auth_response_partial: sameevents[-3]→events[-2]change, plus the twolen(mock_model.requests)assertions drop by 1 (3 → 2 and 4 → 3).Manual End-to-End (E2E) Tests:
A self-contained Runner-based reproduction is at https://github.com/doughayden/adk-issue-examples/tree/main/04-tool_level_auth_continuation. The agent definition (
agent.py) wires up anOpenAPIToolsetagainst a local OAuth2 test server.main.pyconstructs anInMemoryRunner, applies the workaround for #5327 (get_auth_config = lambda: None) at runtime to land on the tool-level auth path, and sends a tool-triggering prompt. The--apply-fixflag monkey-patches the proposed fix to demonstrate the resolution end-to-end.Without the fix:
With the fix:
Checklist
Additional context
Alternative considered:
A reorder of the yields (yield
auth_eventlast solast_event.is_final_response()returns True) would also fix the loop termination in a single iteration without needing the flag. I went withend_invocation = Trueto preserve the observable event order and to match the existing pattern in_resolve_toolset_auth. Happy to switch if maintainers prefer the reorder.Related:
The same yield site at lines 1126-1130 also produces
tool_confirmation_eventfor HITL with the samelong_running_tool_idsshape and the same termination gap. This PR scopes toauth_eventonly. Happy to open a follow-up PR with the same fix fortool_confirmation_eventif the team agrees with the approach here.