fix: yield tool_call_parts immediately in live mode to unblock Gemini 3.1 tool calls#5408
fix: yield tool_call_parts immediately in live mode to unblock Gemini 3.1 tool calls#5408sandeshveerani4 wants to merge 3 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. |
|
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! |
|
Hi @sandeshveerani4 ,Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the failing unit tests before we can proceed with the review. |
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