Skip to content

Live mode tool calls deadlock with Gemini 3.1 Flash Live models #5407

@sandeshveerani4

Description

@sandeshveerani4

Description

Function/tool calling does not work in live (bidirectional streaming) mode when using Gemini 3.1 Flash Live models (e.g., gemini-3.1-flash-live-preview). The model correctly issues tool calls, but they are never executed by the framework, causing the conversation to hang indefinitely.

Root Cause

In GeminiLlmConnection.receive(), tool call parts received via message.tool_call (LiveServerToolCall) are accumulated into tool_call_parts but only yielded in two cases:

  1. When turn_complete is received
  2. When the receive loop exits

Gemini 3.1 Flash Live models send tool calls via LiveServerToolCall and do not emit turn_complete until they receive the tool response. This creates a deadlock:

  1. Model sends tool call → accumulated in tool_call_parts, not yielded
  2. Framework waits for turn_complete to yield the tool call event
  3. Model waits for tool response before sending turn_complete
  4. Neither side makes progress

This works with earlier Gemini 2.x models because they either send tool calls differently or send turn_complete immediately after the tool call.

Steps to Reproduce

  1. Create an agent with any FunctionTool
  2. Use gemini-3.1-flash-live-preview as the model
  3. Start a live session with runner.run_live()
  4. Send a message that triggers a tool call
  5. Observe: the tool call is received by the ADK (visible in debug logs) but the tool never executes, and the model never responds

Expected Behavior

Tool calls should be yielded immediately so the framework can execute them and send responses back to the model.

Proposed Fix

Yield tool_call_parts immediately after receiving message.tool_call instead of deferring until turn_complete. This is safe because:

  • The existing turn_complete yield path handles the case where tool_call_parts is empty (no-op)
  • The post-loop yield path similarly becomes a no-op
  • Earlier models that do send turn_complete after tool calls will still work correctly

Environment

  • google-adk version: 1.31.0
  • Model: gemini-3.1-flash-live-preview
  • Python: 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions