fix: yield tool_call_parts immediately in live mode to unblock Gemini 3.1 tool calls#5408
Open
sandeshveerani4 wants to merge 2 commits intogoogle:mainfrom
Open
fix: yield tool_call_parts immediately in live mode to unblock Gemini 3.1 tool calls#5408sandeshveerani4 wants to merge 2 commits intogoogle:mainfrom
sandeshveerani4 wants to merge 2 commits intogoogle:mainfrom
Conversation
Tool call parts received via LiveServerToolCall were accumulated in tool_call_parts but only yielded when turn_complete arrived or the receive loop exited. Gemini 3.1 Flash Live models send tool calls via LiveServerToolCall and do not emit turn_complete until the tool response is received, causing a deadlock where the framework never executes the tool because it never sees the function call event. Yield tool_call_parts immediately after receiving them so the framework can execute tools and send responses back to the model.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
Response from ADK Triaging Agent Hello @sandeshveerani4, thank you for your contribution! Before we can merge this PR, you will need to sign the Contributor License Agreement (CLA). You can find more information at https://cla.developers.google.com/. Thanks! |
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.
Summary
Fixes #5407
LiveServerToolCallinGeminiLlmConnection.receive()are now yielded immediately instead of being deferred untilturn_completeturn_completeuntil they receive the tool responseProblem
Gemini 3.1 Flash Live models send tool calls via
LiveServerToolCalland wait for the tool response before sendingturn_complete. The current code accumulatestool_call_partsand only yields them onturn_completeor loop exit, creating a deadlock where tools are never executed.Fix
Yield
tool_call_partsimmediately after receivingmessage.tool_call. This is backward-compatible — earlier models that sendturn_completeafter tool calls will still work because the existing yield paths become no-ops whentool_call_partsis already empty.Test plan
gemini-3.1-flash-live-previewin live mode — tool calls now execute on the first message and the model responds with audio after receiving tool resultsturn_complete-based flow