Gemini Live API Random WebSocket Closures After Sendtoolresponse()

Random WebSocket closures after sendToolResponse() on Gemini Live API

Has anyone else run into this?

When I send tool responses via sendToolResponse(), the Gemini Live WebSocket sometimes just dies — either with code 1011 (“Internal error occurred”) or 1008 (“Requested entity was not found”). It doesn’t happen every time, just randomly after a tool call finishes.

The worst part is the error messages are totally opaque. No clue whether it’s the payload size, format, encoding, tool call ID mismatch, or something else. Debugging this is basically guesswork.

I confirmed that this only happens with gemini-2.5-flash-native-audio-preview-09-2025 Downgrading to gemini-live-2.5-flash-preview solves that issue. Unfortunately this model has relatively poor perfomance in other ways.


What’s happening

Actual behavior:

  • Tool runs fine

  • Response gets sanitized and formatted

  • I call sendToolResponse({ functionResponses })

  • WebSocket closes immediately with 1011 or 1008

  • No extra info, no logs, nothing useful

Expected behavior:
Either it should accept the response, or at least tell me why it’s unhappy, like “too large,” “bad format,” or “invalid tool ID.”


Setup details

  • Model: gemini-2.5-flash-native-audio-preview-09-2025

  • Using responseModalities: [Modality.AUDIO] and outputAudioTranscription: {}

  • Tools defined as an array of objects with functionDeclarations

Response format:

{
  functionResponses: [
    {
      id: "uuid-string",
      name: "tool-name",
      response: {
        output: "string-response-content" // plain string, not JSON
      }
    }
  ]
}

Size handling:

  • Max 8k chars for some tools, 3k for others

  • Newlines collapsed, whitespace normalized

  • Warn if over 10k chars but still send


What I’ve noticed

  • Totally random — not linked to specific tools or sizes

  • Long responses might fail more often, but not always

  • Both 1011 and 1008 happen under the same conditions

  • 1008 sounds like a bad tool call ID, but I double-checked and the IDs always match


Open questions

  1. Any hidden limits on characters or encoding in the output field?

  2. Should the output be plain text only, or is JSON-stringified data okay?

  3. What exactly triggers 1008 (“Requested entity was not found”)?

  4. And most importantly — why does it happen randomly?


Honestly, the API’s error output could be way more friendly here. Right now it just feels like shooting in the dark. Anyone figured out what’s actually causing this?

1 Like

Hi @salamanderxing,

I was unable to reproduce this issue on my end. Could you please try using the new gemini-2.5-flash-native-audio-preview-12-2025 model and please let me know if you are still facing the same problem?

:waving_hand: Hello

Not sure it’s exactly the same but perhaps you can find use of this, it seems to be similar issue but it could be tied to the same not properly sensing the end voice resulted in timeouts. Let me know if anything in the link helps if not we will go from there.

Best of luck, ~Cmd.Proton🖖

\ Inconsistent Response Behavior in gemini-2.5-flash-native-audio-preview-09-2025 Voicebot - #8 by CMD_Proton