fix: preserve active UI message parts across merged stream step boundaries (#19324)
## Background Merged UI streams could abort and lose valid continuation text when one source finished a step while another source still had an active text or reasoning part. ## Root Cause The UI stream processor unconditionally replaced its global active text and reasoning maps on every finish-step. The reproduction confirmed that another merged source's subsequent valid delta was then reported as missing. `WorkflowChatTransport` also mirrored that old behavior in its stream normalizer, so changing only the core consumer could split an interleaved part into multiple UI parts and leave the first one stuck in the `streaming` state. ## Summary - Keep active text and reasoning parts open until their explicit end chunks. - Align workflow stream normalization with the new lifetime model by preserving open IDs across `finish-step` while releasing ended IDs for legitimate reuse in later steps. - Add patch changesets for both `ai` and `@ai-sdk/workflow`. - Strengthen workflow compatibility tests to assert exact part boundaries and completion states. ## Testing - Added core regression coverage for text and reasoning parts continuing across interleaved step boundaries. - Updated workflow stream tests to verify error-free, lossless consumption as a single completed part. - Verified well-formed multi-step streams can still reuse part ID `"0"` after the prior part ends. - `pnpm --filter ai exec vitest --config vitest.node.config.js --run src/ui/process-ui-message-stream.test.ts` - `pnpm --filter @ai-sdk/workflow test:node` - `pnpm --filter @ai-sdk/workflow test:edge` - `pnpm check` - `pnpm type-check:full` ## End-to-end Validation - `pnpm -C examples/ai-functions exec tsx src/reproduction/issue-19321-merged-finish-step.ts` — completed successfully with `first half second half` and no missing-part error. ## Related Issues Fixes #19321 Closes #19323 --------- Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com> Co-authored-by: tpsdeveloper13 <197825877+tpsdeveloper13@users.noreply.github.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
b2515843f673d7d9c1289c13d77a0f1bfa43293d
Parent: e76c213
Committed by GitHub <noreply@github.com>
on 8/24/2026, 8:21:30 PM