Network Agent subagent stream text
When I call agent.network(...) and one of the sub-agents needs to ask a follow-up question, the message comes through the data-network stream instead of the regular text stream when using the AI SDK. Most of the data-network payload isn’t useful to me, only the actual text content matters. Shouldn’t that text be streamed through the text chunk instead?
9 Replies
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10384
🔍 If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly.
🙏 Thank you for helping us improve Mastra!
I think you're right that this was a bug. Working on a PR here: https://github.com/mastra-ai/mastra/pull/10396.
Cause: The
transformNetwork function was missing handlers for sub-agent/sub-workflow text events (agent-execution-event-text-delta and workflow-execution-event-text-delta), so they fell through to the data chunk handler and ended up in the data-network stream.
Fix: Added type guards (isAgentExecutionTextChunkType and isWorkflowExecutionTextChunkType) to detect these events and transform them into standard text-delta/text-start chunks—just like the routing agent's text already does.
Now all text from the network (routing agent + sub-agents/workflows) properly flows through the text stream instead of being buried in data payloads.
Files changed:
- client-sdks/ai-sdk/src/transformers.ts - Added text event handling in default case
- client-sdks/ai-sdk/src/utils.ts - Added helper type guardsHey @arpitBhalla ive been trying to reproduce your issue on our uidojo
https://ui-dojo.mastra.ai/ai-sdk/network
When the sub agent responds i see it in the text-deltas not in data-network. What version are you on?
Yes @arpitBhalla there is a case for the above PR, but can you please share a reproduction so we can confirm? Thanks!
i think it was a network agent calling a workflow with a step in which i call the agent(text from this agent don't emit in root)
Thanks. Can you confirm your version?
I'm using
betaThanks, do you have a repo you can share?
in Networks you should be able to get text from data-network, if you look into the steps, they should have output.text or something to be updated on each text delta.
If that's not sufficient we can do the same as we do for workflows, add an extra option to text-deltas are streamed.