The latest handle the provider issued, or null before the first update.
Whether a reconnect is in progress.
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.
OptionaltimeLeftMs: numberTime until the provider closes the connection; undefined when not given.
The connection closed without the consumer asking.
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.
Cancels timers, abandons any attempt in flight and stops retries. Call when the consumer closes the session.
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.
The new handle, when the provider sent one.
Whether the session can be resumed from this point without losing data.
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.
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.
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:
goAwaywith 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.Attempts follow RealtimeSessionResumptionOptions.RetryDelaysMs, each limited by RealtimeSessionResumptionOptions.AttemptTimeoutMs. When every attempt fails it calls
OnReconnectFailedonce and stops. With no handle (resumption disabled, or no update received yet) ConnectionLost returnsfalseand the driver keeps its usual fatal path.