M
MastraAI3mo ago
Ariel

Reasoning part not saved in Mastra Memory message history?

Is reasoning not being saved? I get reasoning streamed in during generation, but when inspecting hte mastra messages table, I only see the text and tool invocation parts. I'd expect any data part to just be saved to the DB, as long as it's not transient: true. EDIT: okay I see the issue. For some reason, it gets saved like this..
{
"format": 2,
"parts": [
{
"type": "reasoning",
"reasoning": "",
"details": [
{
"type": "text",
"text": "The user is asking me to ..."
}
]
}
]
}
{
"format": 2,
"parts": [
{
"type": "reasoning",
"reasoning": "",
"details": [
{
"type": "text",
"text": "The user is asking me to ..."
}
]
}
]
}
The reasoning property seems to be an empty string. I'm on AI SDK v5 beta and the latest mastra beta release. Is there a utility function that converts the Mastra history to a Vercel AI SDK v5 UI message array? I'm not calling Mastra via useChat, but instead I use the memory API to fetch the message history.
6 Replies
Ariel
ArielOP3mo ago
I think I found it -
const { uiMessages } = await memory.query({
threadId: artifactId,
resourceId: projectId,
});
const { uiMessages } = await memory.query({
threadId: artifactId,
resourceId: projectId,
});
Ariel
ArielOP3mo ago
Reasoining data parts are still incompatible with v5. They're missing the state property ("done" for example).
No description
Ariel
ArielOP3mo ago
can I somehow intercept the messages before they get saved to memory? I need to add my own metadata to certain messages.
Tyler
Tyler3mo ago
@Ariel thanks for the report! I think this might be an issue when we're converting from "format: 3" (which should be saved in the db) to "format: 2" in the json you pasted. For intercepting/modifying in a middleware-like API, we're planning on adding that very soon, working on it next week can you open a GH issue with some steps on how to reproduce it?
Mastra Triager
Mastra Triager3mo ago
GitHub
[DISCORD:1399493184358318274] Reasoning part not saved in Mastra Me...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1399493184358318274 Is reasoning not being saved? I get reasoning streamed in during generation, but when ...
Abhi Aiyer
Abhi Aiyer3mo ago
hi @Ariel we're working on our v5 support in a more backwards compatible way. We did find this exact issue in this work so will be fixed soon! I posted an update at the top of the mega issue our plans for better v5 compat https://github.com/mastra-ai/mastra/issues/5470
GitHub
AI SDK v5 Support mega issue · Issue #5470 · mastra-ai/mastra
AI SDK v5 has been released! 🎉 Interim We've also released new @ai-v5 pre-release packages so you can try out v5 in Mastra! 🚀 The new pre-release packages contain a backwards compatibility laye...

Did you find this page helpful?