Skip to content

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
sandeshveerani4:fix/live-tool-call-yield
Open

fix: yield tool_call_parts immediately in live mode to unblock Gemini 3.1 tool calls#5408
sandeshveerani4 wants to merge 2 commits intogoogle:mainfrom
sandeshveerani4:fix/live-tool-call-yield

Conversation

@sandeshveerani4
Copy link
Copy Markdown

Summary

Fixes #5407

  • Tool call parts received via LiveServerToolCall in GeminiLlmConnection.receive() are now yielded immediately instead of being deferred until turn_complete
  • This unblocks function/tool calling for Gemini 3.1 Flash Live models which do not emit turn_complete until they receive the tool response

Problem

Gemini 3.1 Flash Live models send tool calls via LiveServerToolCall and wait for the tool response before sending turn_complete. The current code accumulates tool_call_parts and only yields them on turn_complete or loop exit, creating a deadlock where tools are never executed.

Fix

Yield tool_call_parts immediately after receiving message.tool_call. This is backward-compatible — earlier models that send turn_complete after tool calls will still work because the existing yield paths become no-ops when tool_call_parts is already empty.

Test plan

  • Tested with gemini-3.1-flash-live-preview in live mode — tool calls now execute on the first message and the model responds with audio after receiving tool results
  • Verified no regression with the existing turn_complete-based flow

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.
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 20, 2026

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.

@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Apr 20, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Apr 20, 2026

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

live [Component] This issue is related to live, voice and video chat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Live mode tool calls deadlock with Gemini 3.1 Flash Live models

2 participants