sessionResumption not working

Hi - I’ve tried sending { handle: null }, { handle: undefined }, and {} as sessionResumption in Gemini Live API. But I’m still not getting `message.sessionResumptionUpdate`, even after I speak to it. This is true in both audio modes (half cascade and full native).

Is this expected behavior?

Hi @M_L
This isn’t expected behavior; the server is obligated to return a sessionResumptionUpdate if the key exists, which suggests your SDK might be silently stripping the null value during serialization.

Could you please share the code snippet where you construct the setup object and your WebSocket message listener loop?

Hi @Pannaga_J . Thank you for your repsonse. Here’s the message sent to Chrome (you can see the sessionResumption key being sent). However, I do not get the message.sessionResumptionUpdate field back.

In case it’s relevant, I’m using ephemeral tokens.

Here is a sinppet of the relevant code:

  // somewhere in the class
  const ai = new GoogleGenAI({
      apiKey: this.token,
      httpOptions: {
        apiVersion: "v1alpha",
      },
    });

  const currentSession = await ai.live.connect({
      model: this.config.model,
      callbacks: {
        onopen: () => {
          console.log("Live API connected");
        },
        onmessage: (message: types.LiveServerMessage) => {
          this.handleMessage(message);
        },
        onerror: (e: ErrorEvent) => {
          console.error("Live API error:", e);
        },
      },
      config: {
        responseModalities: this.config.responseModalities,
        tools: this.config.tools,
        systemInstruction: this.config.systemInstruction,
        temperature: 0.0,
        sessionResumption: {
          handle: handle ?? undefined,
        },
        contextWindowCompression: {
          slidingWindow: {
            // Using default parameters for now as per plan
          },
        },
      },
    });

  // later in the class:
  private handleMessage(message: types.LiveServerMessage): void {
    // Check for session resumption update
    if (message.sessionResumptionUpdate) {
      console.log(
        "Received session resumption handle:",
        message.sessionResumptionUpdate,
      );
    }
  }



Hey @M_L,

Here is the Google Docs reference for session resumption:
https://ai.google.dev/gemini-api/docs/live-session#javascript_1

From my experience, the session resumption token is not sent every time or on every turn. It may only appear later in the conversation, especially when the context becomes larger and the service decides it’s needed.

Just sharing this in case it helps someone who is debugging the same behavior.

Thank you @icapora . I can have a whole conversation with the live API (hundreds of messages from gemini live) without yet seeing the message.sessionResumptionUpdate set. Is that expected?

Hello @icapora

Can you give us a timeline on a fix for this issue? If not, is it currently being worked on or no?

Thank you.

1 Like

Hey @Kristina_Fontanez just to clarify (and with a bit of a smile :grinning_face_with_smiling_eyes:): I’m not a Google employee, just another developer running into the same issue.

So I don’t have any visibility into timelines or internal roadmaps — I just shared my experience/workaround here so others can compare notes and hopefully someone from the actual Google team can jump in with an official update.

Thanks for following up on the thread!

@icapora Thanks for the clarification. I appreciate you trying to help!

Hi @M_L, apologies for the delayed response.

When you’re using ephemeral tokens, the model runs in a restricted mode. To get session resumption working, you actually have to authorize it on your backend first. You will need to add session_resumption: {} inside the live_connect_constraints block when you call authTokens.create. If the token itself does not have that permission, the server will just ignore the request from the client side. You can check out the best practices for ephemeral tokens here for more details.

Server does not send the sessionResumptionUpdate right when you connect. It usually waits until there has been at least one meaningful back-and-forth, like a full sentence of audio or text, so it has a solid state to checkpoint. Once that first turn is totally finished, you should see the handle pop up. Please refer here for a good breakdown of how sessions are managed and resumed here.

Thank you!

Thank you for explaining this @Srikanta_K_N and thank you for the link to the documents. I can confirm that this works.

It’s not obvious from the API documents that you need to set a config when creating an ephemeral token. Also, we look at the tutorials rather than API pages. Could you update these pages for future users: