Gemini Live realtime session drops mid-call with 1011 Internal error (websocket closed by Google)

During an active outbound call, the Gemini Live websocket is closed by Google’s server with code 1011 (Internal error encountered). This is a server-side transient failure on
Google’s gemini-3.1-flash-live-preview endpoint, not a bug in our code. The LiveKit Google plugin catches it and auto-reconnects (with session resumption), so the conversation
continues — but there is a noticeable latency gap while the session restarts.

Environment

  • Model: gemini-3.1-flash-live-preview (Google Live API, preview endpoint)
  • livekit-agents 1.6.0 / livekit-plugins-google 1.6.0 / google-genai
  • Architecture: realtime, provider=google, voice=Zephyr

Evidence (logs)

18:29:48 EOU speech=speech_1c22a99aae81 …
18:29:49 ERROR error in receive task: 1011 None. Internal error encountered.
google.genai.errors.APIError: 1011 None. Internal error encountered.
(raised from google/genai/live.py _receive → livekit/plugins/google/realtime/realtime_api.py:1005 _recv_task)
18:29:?? REALTIME … ttft=-1000ms duration=0ms in_tok=0 out_tok=0 ← session restarting
Room: outbound-0ce7e1f6-917001142857, job AJ_UZg8iaZc2WMJ.

Root cause

  • WebSocket close code 1011 = remote server internal error. The Gemini Live model crashed/errored server-side while processing the turn and closed the connection.
  • Preview live endpoints (*-live-preview) are materially less stable than GA endpoints and throw 1011 more often.
  • Confirmed not a code issue on our side — the traceback originates inside google-genai / the LiveKit plugin’s receive loop.

Current handling (already in place — verified in installed plugin)

The LiveKit Google plugin already recovers automatically:

  • realtime_api.py:1066-1069 — _recv_task catches the error and calls _mark_restart_needed(on_error=True).
  • Main loop reconnects up to conn_options.max_retry (default 3) with backoff.
  • Reconnect uses session resumption (realtime_api.py:1119), preserving conversation context.
  • The ttft=-1000ms … in_tok=0 out_tok=0 log line right after the error is this reconnect firing.