How to dictate assistant message ID when using Agent + Memory?
We have a use case where we need to persist some data after generation in our DB, and want to associate it with the assistant message ID.
It would be best if we could dictate that ID to begin with. But it would be okay if we could also just retrieve it from
agent.stream
. We're on 0.21.0
.
Using generateMessageId
does not seem to work for persistence. I could not find a Memory class property that does this either.
We're using the Postgres storage layer for Memory.4 Replies
We landed on a pretty ugly workaround of patching
saveMessages
, generating the memory object inside a closure, where assistantMessageId
is a param, and patching it before saving.
if there's a cleaner way, I'd love to know.📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/8952
GitHub
[DISCORD:1428430169646960721] How to dictate assistant message ID w...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1428430169646960721 We have a use case where we need to persist some data after generation in our DB, and ...
Hi @Ariel ! You can get the generated assistant message id from the
response.uiMessages
property :
is this going to be the same ID as the ID stored in the Mastra memory DB?