How to fetch memory in a workflow?
Hi, I have one main Workflow as the entry point of the app and which uses 2 agent in the flow, one after another and few maps in between. I have a storage option set while creating an instance of mastra, i.e.,
new Mastra({..., storage: .... }). I have NOT set memory options on any agents. Now few questions around it:
1. Each and every run on my main workflow will be stored in the storage right?
2. How to retrieve those workflow memory objects of each run?
3. How to set Resource and Thread in a Workflow for a particular User?
4. How to use Resource and ThreadId to give context to the agents while being called by the main workflow?
Any example that can be shared?3 Replies
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/9686
GitHub
How to fetch memory in a workflow? · Issue #9686 · mastra-ai/mastra
This issue was created from Discord post 1434973887392645305: Hi, I have one main Workflow as the entry point of the app and which uses 2 agent in the flow, one after another and few maps in betwee...
Hi @Jenil !
1. yes, so long you have storage setup on the Mastra instance
2. where are you looking at doing that? from withing a workflow step, from the client sdk? elsewhere?
3. workflows are not stored using thread & resource ids, but you can pass these using the
runtimeContext
4. you can get the runtimeContext form the step execute args, and then pass that to the agent.
Hi @Romain , I have this flow of code. Now in your example above, you have passed the runtime context directly, will it work in my case too below? Not using client-sdk yet for anything. Backend is hosted and connected via Websocket.
2 more question:
- How will I load the previous history conversation in UI from my
mainWorkflow which is the entry point of the app, I want to load the input and response of my each workflow executions? I am working on a chatbot.
- How to pass last 10 messages in the agent with threadId and resourceId from runtimecontext?