Progressive Text Streaming Broken in Workflow Steps After stream() Migration
Problem:
After migrating from streamVNext() to stream(), text streaming from agents within workflow steps no longer propagates to the
workflow's stream.
Evidence:
Backend logs confirm 566 chunks generated over 25s, but workflow stream only receives:
{"type":"step-start","payload":{"id":"my_step"}}
{"type":"step-result","payload":{"id":"my_step","output":{...}}}
NO text chunks appear between these events.
What We've Tried:
1. Manual iteration with writer.write():
for await (const chunk of stream.textStream) {
await params.writer.write({ type: 'text-delta', text: chunk })
}
Result: Chunks don't emit to workflow stream
2. Using streamVNext() with pipeTo():
await stream.pipeTo(params.writer)
Result: TypeScript errors - pipeTo doesn't exist, streamVNext deprecated
Question:
How do we stream agent text chunks from within a workflow step using the new stream() API?
Minimal Example:
export const myStep = createStep({
id: 'my_step',
execute: async (params: any) => {
const stream = await agent.stream([...])
// How to emit chunks to workflow stream?
for await (const chunk of stream.textStream) {
// Need in workflow.stream() iterator
}
return await stream.text
}
})
Is there a new pattern for nested streaming with stream() API?
5 Replies
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8914
GitHub
[DISCORD:1428187473623908435] Progressive Text Streaming Broken in ...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1428187473623908435 Problem: After migrating from streamVNext() to stream(), text streaming from agents wi...
Hi @OG ! Let me check, but I'm not sure you should be using
stream
yet for workflowsif you use streamVNext it says -
streamVNext has been renamed to stream. Please use stream instead.
at Ra.streamVNext (/var/task/index.js:427:10759)
at /var/task/index.js:47:44268
but stream doesnt cascade the stream from agent to workflow @Romain
hi btw 👋
also the docs says use streamLegacy instead of streamVNext but that also erors with V2 models are not supported for streamLegacy. Please use stream instead.
pretty un usable atm
ok - i think ive worked around it - you can still use streamVNext with a workflow but not with an agent !
on 0.21.1 i can stream a workflow with .streamVNext and the agent with .stream and that worksYes, sorry it's still a little confusing, but workflows still need to use
streamVNext
, we should bw moving to stream
very soon 😉thank you 🙏