using `writer.custom()` for UI framework integration

Hey team! 👋 I'm trying to implement tool streaming with custom events following the docs here: https://mastra.ai/en/docs/streaming/tool-streaming#using-the-writer-argument The docs show using writer.custom() for UI framework integration:
await writer?.custom({
type: "data-tool-progress",
status: "pending"
});
await writer?.custom({
type: "data-tool-progress",
status: "pending"
});
However, I'm getting TypeError: writer?.custom is not a function at runtime. Environment: - @mastra/core@0.21.1 (all Mastra packages on 0.21.x) - Verified with npm list @mastra/core - all dependencies properly deduplicated What I found: Looking at node_modules/@mastra/core/dist/tools/stream.d.ts, the ToolStream class only has a write() method, not custom():
export declare class ToolStream<T> extends WritableStream<T> {
write(data: any): Promise<void>;
// ❌ No custom() method
}
export declare class ToolStream<T> extends WritableStream<T> {
write(data: any): Promise<void>;
// ❌ No custom() method
}
Questions: 1. Is writer.custom() available in 0.21.1, or is this a docs issue? 2. If it's coming in a future release, when can we expect it? (0.21.2, 0.22.0?) Thanks! 🙏
Tool Streaming | Streaming | Mastra
Learn how to use tool streaming in Mastra, including handling tool calls, tool results, and tool execution events during streaming.
5 Replies
! .kinderjaje
! .kinderjaje2d ago
I dont know if its related, but I think its similiar to the issue I reported over here https://discord.com/channels/1309558646228779139/1427185080144498709 . In short, try with alpha for all Mastra packages and see if its gonna work. But keep in mind maybe its unrelated. @spo0nman
spo0nman
spo0nmanOPthis hour
I see that @mastra/core 0.22.0 • Public • Published 7 minutes ago ... it seems to have writer.custom()
! .kinderjaje
! .kinderjajethis hour
yeah, seems the released new package
spo0nman
spo0nmanOP22h ago
here are full details. Ward's Finding: transformNetwork() filters custom events (network routing issue) AgentStreamToAISDKTransformer does preserve custom events my Issue: using agent.stream() (not network), so I should hit the good transformer BUT crashing with: Cannot use 'in' operator to search for 'type' in undefined This happens before it can check for data- prefix
Mastra Triager
Mastra Triager20h ago
GitHub
[DISCORD:1430420806990561311] using writer.custom() for UI framew...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1430420806990561311 Hey team! 👋 I&#39;m trying to implement tool streaming with custom events following th...

Did you find this page helpful?