`toUIMessageStreamResponse` also includes tool calls - how to filter out?
Hi all,
I'm using AI SDK 5 with NextJS. When I call
toUIMessageStreamResponse
in /chat
endpoint, the function returns all data, like messages and tool calls. As I want to build a public agent, I only want to return text messages, but not tool calls. How can I achieve this?
I followed this tutorial here, so I guess my setup is fine: https://mastra.ai/en/examples/agents/ai-sdk-v5-integration
This is the code that is relevant:
installed packages:
6 Replies
I check the implementation, and I guess the reason why all data is included in the
toUIMessageStreamResponse
is, that it is using fullStream
: https://github.com/mastra-ai/mastra/blob/b6a492903f63650e9b7e9d6ce95c232f24a4ce45/packages/core/src/stream/aisdk/v5/output.ts#L121📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8966
GitHub
[DISCORD:1428677895936807026]
toUIMessageStreamResponse
also incl...This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1428677895936807026 Hi all, I'm using AI SDK 5 with NextJS. When I call toUIMessageStreamResponse in /...
@hefe.woiza why not only filter it out on the frontend? If not you could write a custom transformer in your post to clean the stream
why not only filter it out on the frontendbecause:
As I want to build a public agent,Some implementation details must be hidden I believe
exactly. also, the tool is calling a rag api which is returning quite some data and i don't want to have that massive traffic