M
Mastraโ€ข2w ago
arpitBhalla

How to save `data-` emitted from workflows in storage?

I've added memory to an agent which generates object, it's storing the output in DB, but the steps emits some data-* which aren't stored. Right now, I am using this, but not sure how to convert chunks to parts/MastraDBParts. (And it's not working as chunks have text-delta and parts have only text) Wanted to understand what's basic difference in storage and memory, and if there's way I can save eveything that's being stream to DB?
const uiMessageChunks: UIMessageChunk[] = [];
for await (const chunk of toAISdkStream(stream.fullStream, {})) {
writer.write(chunk as UIMessageChunk);
uiMessageChunks.push(chunk);
}
await mastra.getStorage()?.saveMessages({
messages: [
{
id: uuid(),
role: 'assistant',
threadId: context.get('threadId'),
resourceId: context.get('resourceId'),
createdAt: new Date(),
type: 'assistant',
content: {
format: 2,
parts: uiMessageChunks,
},
},
],
});
const uiMessageChunks: UIMessageChunk[] = [];
for await (const chunk of toAISdkStream(stream.fullStream, {})) {
writer.write(chunk as UIMessageChunk);
uiMessageChunks.push(chunk);
}
await mastra.getStorage()?.saveMessages({
messages: [
{
id: uuid(),
role: 'assistant',
threadId: context.get('threadId'),
resourceId: context.get('resourceId'),
createdAt: new Date(),
type: 'assistant',
content: {
format: 2,
parts: uiMessageChunks,
},
},
],
});
2 Replies
Mastra Triager
Mastra Triagerโ€ข2w ago
๐Ÿ“ Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10582 ๐Ÿ” 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 Aiyerโ€ข2w ago
Hi @arpitBhalla we are working on this issue here https://github.com/mastra-ai/mastra/issues/10582 Thanks for reporting we will fix!
GitHub
How to save data- emitted from workflows in storage? ยท Issue #10...
This issue was created from Discord post 1443430644893089822: I've added memory to an agent which generates object, it's storing the output in DB, but the steps emits some data-* which aren...

Did you find this page helpful?