toAISDKStream Not Returning Reasoning Output

I’ve configured a simple agent with reasoning enabled in the provider options. When I test it in Studio, I can see the reasoning coming through correctly. However, when I call it via toAISDKStream, there doesn’t appear to be any reasoning in the response. Does toAISDKStream support reasoning, or am I missing a configuration step?
No description
No description
4 Replies
rickyh3
rickyh3OP3w ago
I ended up adding the options to directly and now it passes a reasoning step - but still doesn't stream the reasoning-delta chunks for the reasoning step (only sends the reasoning-start and reasoning-end).
No description
No description
Mastra Triager
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10398 🔍 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!
Abhi Aiyer
Abhi Aiyer3w ago
Hey @rickyh3 let me look into this. Its probably missing a transform somewhere!
Grayson
Grayson3w ago
I think this can be solved with the sendReasoning option, but looks like we need to update some docs on this!
const agentStream = await generalAgent.stream(message, {
requestContext,
memory: {
thread: id,
resource: session.user.id,
},
providerOptions: {
openai: { reasoningEffort: "high", reasoningSummary: "detailed" },
}
});

// Create a Response that streams the UI message stream to the client
return createUIMessageStreamResponse({
stream: toAISdkStream(agentStream, {
from: "agent",
sendReasoning: true // ← Add this!
}),
});
const agentStream = await generalAgent.stream(message, {
requestContext,
memory: {
thread: id,
resource: session.user.id,
},
providerOptions: {
openai: { reasoningEffort: "high", reasoningSummary: "detailed" },
}
});

// Create a Response that streams the UI message stream to the client
return createUIMessageStreamResponse({
stream: toAISdkStream(agentStream, {
from: "agent",
sendReasoning: true // ← Add this!
}),
});
Adding some docs here: https://github.com/mastra-ai/mastra/pull/10404

Did you find this page helpful?