I am building an app with the ai-sdk, and I am using the streamText function to stream messages to the frontend. However, I noticed that the results of tool calls are also being sent to the frontend.
Is there a way to restrict or control which tool results are sent to the frontend?
Code Example
const result = streamText({
model: groq("moonshotai/kimi-k2-instruct-0905"),
tools,
stopWhen: stepCountIs(5),
messages: modelMessages,
});
result.pipeUIMessageStreamToResponse(res, {
onFinish({ responseMessage }) {
console.log("Response message: ", responseMessage);
},
});