Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(flows): terminate invocation at tool-level EUC
- 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)
  • Loading branch information
doughayden committed May 7, 2026
commit 7ebd8c27ba4fd3eb532842c0b135c761fe5cfab3
3 changes: 3 additions & 0 deletions src/google/adk/flows/llm_flows/base_llm_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,9 @@ async def _postprocess_handle_function_calls_async(
if auth_event:
yield auth_event

# Interrupt invocation (mirrors _resolve_toolset_auth behavior)
invocation_context.end_invocation = True

tool_confirmation_event = functions.generate_request_confirmation_event(
invocation_context, function_call_event, function_response_event
)
Expand Down
10 changes: 6 additions & 4 deletions tests/unittests/flows/llm_flows/test_functions_request_euc.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ def call_external_api2(tool_context: ToolContext) -> Optional[int]:
== auth_configs[idx].raw_auth_credential
)

assert len(mock_model.requests) == 1


def test_function_get_auth_response():
id_1 = 'id_1'
Expand Down Expand Up @@ -309,7 +311,7 @@ def call_external_api2(tool_context: ToolContext) -> int:
)
runner = testing_utils.InMemoryRunner(agent)
runner.run('test')
request_euc_function_call_event = runner.session.events[-3]
request_euc_function_call_event = runner.session.events[-2]
function_response1 = types.FunctionResponse(
name=request_euc_function_call_event.content.parts[0].function_call.name,
response=auth_response1.model_dump(),
Expand Down Expand Up @@ -505,7 +507,7 @@ def call_external_api2(tool_context: ToolContext) -> int:
)
runner = testing_utils.InMemoryRunner(agent)
runner.run('test')
request_euc_function_call_event = runner.session.events[-3]
request_euc_function_call_event = runner.session.events[-2]
function_response1 = types.FunctionResponse(
name=request_euc_function_call_event.content.parts[0].function_call.name,
response=auth_response1.model_dump(),
Expand All @@ -531,7 +533,7 @@ def call_external_api2(tool_context: ToolContext) -> int:
)

assert function_invoked == 3
assert len(mock_model.requests) == 3
assert len(mock_model.requests) == 2
request = mock_model.requests[-1]
content = request.contents[-1]
parts = content.parts
Expand All @@ -550,7 +552,7 @@ def call_external_api2(tool_context: ToolContext) -> int:
),
)
assert function_invoked == 4
assert len(mock_model.requests) == 4
assert len(mock_model.requests) == 3
request = mock_model.requests[-1]
content = request.contents[-1]
parts = content.parts
Expand Down