Member Junction
    Preparing search index...

    Class RealtimeSessionResumption

    Decides when a realtime session with provider-side resumption moves to a new connection, and drives the move. It holds no transport: the driver reports what the provider says and supplies the call that opens the replacement connection.

    Two triggers:

    • The connection is ending (ConnectionEnding). Gemini Live sends goAway with the time left before it closes a connection; the notice varies (on Vertex AI it came about 9 minutes after the connection opened, with 30 s left). The helper reconnects at the next resumable point, because resuming from an older handle drops whatever happened since it was issued. A resumable point is a handle the provider marks resumable, issued while no turn is in progress: the driver reports turns (TurnStarted, TurnEnded), because a provider's own word is not enough (Vertex AI marks every update resumable, mid-answer too). If no resumable point arrives, it reconnects with the last handle shortly before the deadline: a third of the notice before it, between REALTIME_RESUMPTION_MIN_DEADLINE_MARGIN_MS and RealtimeSessionResumptionOptions.DeadlineMarginMs.
    • The connection was lost (ConnectionLost): a network change or a server reset. The helper reconnects with the last handle.

    Attempts follow RealtimeSessionResumptionOptions.RetryDelaysMs, each limited by RealtimeSessionResumptionOptions.AttemptTimeoutMs. When every attempt fails it calls OnReconnectFailed once and stops. With no handle (resumption disabled, or no update received yet) ConnectionLost returns false and the driver keeps its usual fatal path.

    Index

    Constructors

    Accessors

    Methods

    • The provider announced the current connection ends in timeLeftMs. The helper moves at once when the latest handle is a resumable point (issued after the last turn ended, with no turn since); otherwise it waits for one, until the deadline.

      Parameters

      • OptionaltimeLeftMs: number

        Time until the provider closes the connection; undefined when not given.

      Returns void

    • The connection closed without the consumer asking.

      Returns boolean

      true when a reconnect started (or was already running), so the driver reports "reconnecting" rather than an error; false when there is no handle to resume from, so the driver keeps its fatal path.

    • Records the provider's latest resumption state. resumable: false means the session is mid-generation or mid-tool-call: the previous handle stays as a fallback for a lost connection, but a planned move waits for the next resumable point. A resumable handle that arrives while a turn is in progress is kept as that fallback too: resuming from it would cut the turn, so it is not a point to move at.

      Parameters

      • handle: string

        The new handle, when the provider sent one.

      • resumable: boolean

        Whether the session can be resumed from this point without losing data.

      Returns void

    • The turn ended (its turnComplete, with no tool call pending). A planned move now happens at the next resumable handle, which the provider issues after the turn (Vertex AI: 20-70 ms after turnComplete), so the new connection resumes with the finished turn.

      Returns void

    • A turn started or continued: the user's first transcribed words, a turn the client sent, or the model's output. Until TurnEnded, a planned move waits, whatever the provider's updates say; the deadline still bounds the wait. Call it for every sign of the turn: a repeat changes nothing.

      Returns void