Skip to content

Commit a819882

Browse files
committed
docs(sdk): note AgentChat.reconnect resumes a stream, not a fresh turn
1 parent 74c9e7d commit a819882

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

packages/trigger-sdk/src/v3/chat-client.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,18 @@ export class AgentChat<TAgent = unknown> {
577577
}
578578

579579
/**
580-
* Reconnect to the response stream (e.g. after a disconnect). Requests the
581-
* caught-up settle probe (`X-Peek-Settled`) so a resumed stream already at a
582-
* turn-complete tail closes promptly instead of holding the full SSE window,
583-
* mirroring the browser transport's `reconnectToStream`.
580+
* Reconnect to the response stream to resume an already-established session
581+
* after a disconnect. Requests the caught-up settle probe (`X-Peek-Settled`)
582+
* so a resumed stream already at a turn-complete tail closes promptly instead
583+
* of holding the full SSE window, mirroring the browser transport's
584+
* `reconnectToStream`.
585+
*
586+
* Do not call this immediately after `sendMessage()` to read a fresh turn: the
587+
* settle probe can race the newly-triggered turn's first record, see the prior
588+
* turn's `turn-complete` tail, and hand back an empty stream (unlike the
589+
* browser transport, there is no auto-resubscribe). `sendMessage()` already
590+
* returns the turn's stream; use `reconnect()` only to resume an idle or
591+
* mid-turn stream.
584592
*/
585593
async reconnect(abortSignal?: AbortSignal): Promise<ReadableStream<UIMessageChunk> | null> {
586594
if (!this.state.started) return null;

0 commit comments

Comments
 (0)