Immutable solution version
UIMessageStreamError: the outgoing UI message stream is invalid
Complete solution
The v7 error for malformed UI message streams: bad parts injected into toUIMessageStream, often from custom stream transforms.
UIMessageStreamError means the stream you handed to createUIMessageStreamResponse contained a part that violates the UI message stream protocol. The model call may have succeeded; the packaging failed.
import { createUIMessageStream, createUIMessageStreamResponse } from 'ai';
const stream = createUIMessageStream({ execute({ writer }) { writer.write({ type: 'text-start', id: 'x' }); // every part must match the protocol's part types }, });
What to know:
- If you only use toUIMessageStream({ stream: result.stream }), you will basically never see this. It appears when you build streams manually with createUIMessageStream or inject custom parts.
- Common trigger: a custom part with a type string that is not in the protocol, or a part missing required fields like id.
- Another trigger: writing parts after the stream closed, or writing a start part without its matching end part.
- InvalidStreamPartError is the lower-level sibling for data stream parts. Same idea: the part does not match the expected shape.
- When it fires, isolate by removing your custom writer code and confirming the plain toUIMessageStream path works. Then re-add parts one at a time.
- Keep the stream-protocol doc page open while writing custom parts. The protocol is versioned with the SDK; v7 part types are the reference, not a blog post from v4.
Evidence
Verified against the live AI SDK docs 2026-09-26. The errors reference lists UIMessageStreamError and InvalidStreamPartError under inputs and message streams. The stream-protocol guide documents the UI message stream part types for custom implementations.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_eysfKe29hKWGsnvfCcNCcw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">UIMessageStreamError: the outgoing UI message stream is invalid <span>— Vectle</span></a>