Skip to content

fix(flows): end invocation on a deferred long-running tool call#1324

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_942089477
Jul 3, 2026
Merged

fix(flows): end invocation on a deferred long-running tool call#1324
copybara-service[bot] merged 1 commit into
mainfrom
test_942089477

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Jul 3, 2026

Copy link
Copy Markdown

fix(flows): end invocation on a deferred long-running tool call

A long-running tool (e.g. a human-in-the-loop request) that returns no
immediate result defers its response until the caller supplies it later.
The framework built an empty function-response for such a call and
re-invoked the model with that placeholder, so the model proceeded on an
empty result -- fabricating a completion, or in multi-tool agents
re-issuing calls in a runaway loop until the LLM call limit.

  • Skip the function-response event when a long-running tool returns null or
    an empty result, so no placeholder is sent back to the model.
  • Treat an event that carries pending long-running tool-call ids as a final
    response, so the invocation ends and returns control to the caller.
  • Guard LlmAgent output-key writes so a text-less final event (such as the
    long-running call itself) no longer overwrites the output key with an
    empty string.

This brings Event.finalResponse() to parity with ADK Python's
Event.is_final_response, which returns true when long_running_tool_ids is
set (in both the 1.x and 2.0 branches), and the output-key guard mirrors
ADK Python's output_key handling.

@copybara-service copybara-service Bot force-pushed the test_942089477 branch 8 times, most recently from 81781de to e8dd200 Compare July 3, 2026 15:02
A long-running tool (e.g. a human-in-the-loop request) that returns no
immediate result defers its response until the caller supplies it later.
The framework built an empty function-response for such a call and
re-invoked the model with that placeholder, so the model proceeded on an
empty result -- fabricating a completion, or in multi-tool agents
re-issuing calls in a runaway loop until the LLM call limit.

- Skip the function-response event when a long-running tool returns null or
  an empty result, so no placeholder is sent back to the model.
- Treat an event that carries pending long-running tool-call ids as a final
  response, so the invocation ends and returns control to the caller.
- Guard LlmAgent output-key writes so a text-less final event (such as the
  long-running call itself) no longer overwrites the output key with an
  empty string.

This brings Event.finalResponse() to parity with ADK Python's
Event.is_final_response, which returns true when long_running_tool_ids is
set (in both the 1.x and 2.0 branches), and the output-key guard mirrors
ADK Python's output_key handling.

PiperOrigin-RevId: 942146191
@copybara-service copybara-service Bot merged commit 6dd4594 into main Jul 3, 2026
@copybara-service copybara-service Bot deleted the test_942089477 branch July 3, 2026 15:08
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.

1 participant