Skip to content

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

Closed

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

Activity

  1. added
    live
    on Apr 20, 2026
  2. sanketpatil06 commented on Apr 21, 2026

    @sanketpatil06

    Hi @sandeshveerani4 , Thank you for reporting this issue and taking the time to raise a PR.

    We were able to reproduce the issue on our end and observed the exact behavior you described. Your PR is currently being reviewed by our engineering team and will be merged once approved.

    We greatly appreciate your contribution.

  3. added
    needs review
    on Apr 21, 2026
  4. surajksharma07 commented on Apr 30, 2026

    @surajksharma07
    Collaborator

    @sasha-gitg Please have a look into it once.

  5. added a commit that references this issue on Apr 30, 2026
    f57b05d
  6. added a commit that references this issue on Aug 11, 2026
    02e1a01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

liveneeds review

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions