What this thread does
Do first: use DefaultChatTransport with the server's UI message stream, then choose client-side cancellation with resumption disabled or resumable generation before enabling abort propagation.
Short answer
As of November 2026, pair AI SDK 7.0.0 with @ai-sdk/react 4.0.0 from the same release tag. Render message parts and tool states.
Choose / don't choose
- Ordinary cancellation: choose when Stop should end generation; don't combine request aborts with resumable producer persistence.
- Resumable generation: choose when generation must survive disconnects; don't infer producer cancellation from the browser closing (abort/resume boundary).
- Server/client tools: choose server
executefor server operations,onToolCallplusaddToolOutputfor automatically executed client-side tools; don't execute the same effect on both sides (tool guide).
Not for: resumable stream producers; see ai-chat-reply-lost-on-refresh-resumable-streams-stop-button; chat component choice; see ai-elements-chat-ui-vercel-ai-sdk.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
transport, api | new DefaultChatTransport({ api: '/api/chat' }) | AI SDK current UI docs | chat |
createUIMessageStreamResponse, toUIMessageStream | Return createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }) }) after await convertToModelMessages(messages) | AI SDK current UI docs | route |
execute, stopWhen | Tools with an execute function run automatically as the model calls them; stopWhen: isStepCount(5) caps multi-step continuation at five steps | AI SDK current core docs | tool loop |
sendAutomaticallyWhen | lastAssistantMessageIsCompleteWithToolCalls automatically submits when all tool results are available; lastAssistantMessageIsCompleteWithApprovalResponses for approval continuation | AI SDK current UI docs | continuation |
resume | false disables stream resumption; true selects a conflicting resumable lifecycle | AI SDK current docs | resume boundary |
abortSignal, supportsCancellation | Forward req.signal to streamText; on Vercel, cancellation requires Node.js; set function supportsCancellation: true in vercel.json | Vercel Node.js deployment | stopping |
Order of operations
1. Convert incoming UIMessage[], call streamText, return the UI stream, and render message.parts (chat). 2. Render input-streaming and input-available as pending; output-available as a result; output-error with errorText; include approval-requested, approval-responded, and output-denied. Preserve toolCallId. Do not await addToolOutput inside onToolCall (tools). 3. Stop calls stop() while submitted/streaming. Host cancellation reaches req.signal, then the model through abortSignal. (stopping, tool options). 4. Record a user stop separately from hook error or a disconnected response. Before retrying an uncertain mutation, look up its business operation result; use server-enforced idempotency if replay is allowed. This is application policy, not an SDK rollback guarantee. 5. For mismatched package generations, upgrade client/server together and apply npx @ai-sdk/codemod v7, then inspect stream adapters and tool-part renderers. The migration renames stepCountIs to isStepCount and changes other core APIs (migration).
Known failures and fixes
| Error or symptom | Cause | Fix | Source |
|---|---|---|---|
output-error | Tool error reported using output-error | Record errorText with addToolOutput; show the failed tool separately | tool error handling |
| Stop leaves producer running (symptom) | Historical report, closed as completed on 2026-08-11: resumable stream did not stop when an abort signal was sent | Select the intended lifecycle and inspect producer termination; enable Vercel function cancellation where applicable | kaijiabo, May 27, 2025, #6502, host setting |
Missing
- The linked source does not confirm: a disconnected response cannot establish whether a mutating tool completed.
- The linked source does not confirm: completed effects remain completed
- The linked source does not confirm: Tools must pass their cancellation signal to downstream operations and handle it cooperatively
- No general tool rollback or exactly-once guarantee. A stop or lost stream alone cannot prove a side effect did not happen.
- Package pairing above is a release baseline, not permission to mix arbitrary future UI/core versions.
Checked
2026-11-12; release and tagged React package, chat/tool/core references, stopping and resumption guides, migration, and contributor report read. No chat or provider commands executed.
Started from a post by @Vercel, packaged by the editor. Original post