What this thread does
The problem
A user reloads, closes a laptop, or drops off Wi-Fi in the middle of a long reply. The partial answer is lost and, if the model was still generating, you paid for tokens nobody saw.
What the AI SDK docs describe (as fetched October 2026)
The "Chatbot resume streams" page lists three requirements: the resumable-stream package, Redis to store the UI message stream, and a persistence layer (a database) that records each chat's activeStreamId.
- Client: pass
resumetouseChat; on mount the hook checks for an active stream and reconnects. By default a resumed stream is treated as a full replay; if your endpoint sends only remaining chunks setresumeStreamIsReplay: falseon the transport, but use a full replay after a page reload because active text and reasoning continuation requires the same chat instance. - Server, GET route (for example
app/api/chat/[id]/stream/route.ts): read the chat; ifactiveStreamIdis null returnnew Response(null, { status: 204 }); otherwise returnstreamContext.resumeExistingStream(chat.activeStreamId)with the UI message stream headers. - POST route: create the stream in
consumeSseStream, save theactiveStreamId, and clear it inonEndwhen generation finishes.
The stop button gotcha
The docs say that with resumable streams, stop() and client aborts only close the HTTP connection: the server keeps generating so the client can reconnect. A real stop button needs a dedicated endpoint that saves the partial assistant message, cancels the work producing the stream, and clears activeStreamId only if it still matches the stream being stopped. Call it only on explicit user action, not from route cleanup, and do not auto-reconnect after the user stops.
Tian Pan's November 2025 article describes the same architecture in general terms (generator writes chunks to a Redis Stream, a consumer forwards over SSE, clients resume from their last position) and adds a cancel path via AbortController so abandoned generations stop costing money.
A prompt for your agent
Add resumable streams to the chat route following the AI SDK "resume streams" docs: Redis-backed resumable-stream, activeStreamId stored on the chat row, a GET resume route that returns 204 when idle, and resume on useChat. Then add a separate stop endpoint that cancels generation and clears activeStreamId only if it matches. Do not auto-reconnect after an explicit stop.
Mistakes to avoid
- Adding
resumeand keepingstop()as the only cancel path, so "stopped" chats keep billing. - Forgetting to clear
activeStreamIdon finish, so every reload tries to resume a finished stream. - Treating it as a UI feature: it needs Redis and a column in your chat table.
Limits
Source is the AI SDK documentation; I did not run it and the docs do not report cost or reliability numbers. It adds an infrastructure dependency (Redis).
Sources
Primary source: the AI SDK page Chatbot resume streams, read on 18 October 2026.
- Confirms: the three requirements (
resumable-stream, Redis, a storedactiveStreamId),resumeonuseChat,resumeStreamIsReplay: falsefor partial-chunk endpoints, the GET route returning 204 when idle and otherwiseresumeExistingStream, the POST route saving the id inconsumeSseStreamand clearing it inonEnd,stop()only closing the connection while generation continues, a dedicated stop endpoint that saves the partial message and clears the id only if it still matches, and no auto-reconnect after a stop. - Not covered: Tian Pan's article (secondary, not re-opened) and any cost or reliability figures.
Started from a post by @Vercel AI SDK docs, packaged by the editor. Original post