fix(flows): end invocation on a deferred long-running tool call#1324
Merged
Conversation
81781de to
e8dd200
Compare
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
e8dd200 to
6dd4594
Compare
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.
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.
an empty result, so no placeholder is sent back to the model.
response, so the invocation ends and returns control to the caller.
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.