Skip to content

Google Realtime plugin silently swallows empty Gemini responses (port of agents#4249) #1450

@dbloembe

Description

@dbloembe

Bug Description

The @livekit/agents-plugin-google Realtime plugin silently ignores empty server content from Gemini, causing the agent to enter speaking state with no audio output. This is the JS equivalent of the bug fixed in the Python SDK by livekit/agents#4249.

Current Behavior

In realtime_api.ts (line ~1132), when Gemini returns a response with no meaningful server content, the plugin silently drops it:

if (!hasServerContent) {
  response.serverContent = undefined;
  if (LK_GOOGLE_DEBUG) {
    this.#logger.debug('ignoring empty server content');
  }
}

When Gemini sends turnComplete with empty content (a known server-side bug), the generation is marked done but no audio was produced — the agent "speaks" silence.

Expected Behavior

Match the Python SDK fix (PR #4249): raise an APIStatusError on empty responses so the SDK's retry/fallback mechanisms can recover, rather than silently accepting a failed turn.

Impact

In production phone ordering calls using gemini-3.1-flash-live-preview, we observe ~50% of deployed calls experiencing at least one silent stall. The agent enters speaking state but produces no audio. The WebSocket stays open, no error events fire. Our application-level stall recovery (realtime text nudge after 8s) catches most of these, but the plugin should handle this at the source.

Environment

  • @livekit/agents-plugin-google: 1.3.4 (also verified in 1.4.0 — still present)
  • @livekit/agents: 1.3.4
  • Model: gemini-3.1-flash-live-preview
  • Runtime: Node.js on LiveKit Cloud (us-east)

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions