Skip to Content

resumeStream

resumeStream(options: ResumeStreamOptions): Promise<ResumeStreamResult>

Defined in: src/lib/chat/resumeStream.ts:219 

Replay a detached stream from the portal’s buffer.

This is the reconnect primitive: after runToolLoop returns the detached variant with a StreamResumeHandle, resumeStream issues a GET to the portal’s replay endpoint and rebuilds the response from seq 0 using a FRESH accumulator and FRESH smoothers. Nothing from the original (detached) run is reused — the completions strategy’s reasoning-tag parser is stateful, so replaying into reused state would double-count; replay-from-0 into fresh state is the correctness mechanism, not just a simplification.

Contract highlights:

  • No starting_after, no id: cursor, no body. The GET carries the inference id in the path only; replay is always whole-stream. (The server reserves starting_after but does NOT honor it — sending it would silently duplicate content.)
  • 410 → throws StreamExpiredError. No onFinish/onError.
  • In-stream error / tool-request terminal → interrupted: true. Flushes both smoothers and returns the partial; no throw, no onError, no onFinish.
  • token resolved by the caller at resume time so a refresh during the detach window is honored.

Parameters

ParameterType

options

ResumeStreamOptions

Returns

Promise<ResumeStreamResult>

Last updated on