Entry/Wrapper needs memory so that other agent dowstream can have memory, why?
I have a setup where we had a
entryWorkflow with 2 agents being called. AgentA has memory and AgentB does not.
Can we have conversational chat with this setup? From what I have found, we cannot have previous context in a workflow with agent having or not having memory in it. Is that right?
Now, to resolve that I had to introduce a wrapperAgent with memory which now calls my entryWorkflow. Now my wrapperAgent does not just call and return raw output from worflow execution. After few chat, it starts interpreting and sometimes appending previous answers with the new result. It breaks the stability. If I don't give memory to this wrapperAgent so as to stablise it, where it give the execution output and do not have previous, then the downstream agentA for some reason does have context of previous conversation.
What can be done here? I have tried outputProcessor but did not help as agent only gives the appending or interpreted result back. I can do some shabby engineering around the response but wanted to check if anything sophisticated is available that can resolve this?5 Replies
Will working memory help here?
I assume you're referring to the working memory of the agents here, which are Thead-Scoped by default.
Though you should be able to define the working memory configuration of the agent via a callback that receives the
RuntimeContext in order to decide which memory configuration to use based on arguments you can provide per agent call.
You could either use a different scope per agent, disable working memory or even use a different storage depending on the call.Working Memory | Memory | Mastra Docs
Learn how to configure working memory in Mastra to store persistent user data, preferences.
š Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10231
š If you're experiencing an error, please provide a minimal reproducible example to help us resolve it quickly.
š Thank you @Jenil for helping us improve Mastra!
Working memory was an alternative that could work, is what I was checking. The original question was referring here to the contextual conversation memory. Every agent, that needs conversation memory and has a parent agent, require parent agent also to have memory enabled on it?
Afaik there is no conversation history scoped to a workflow. If you need full control over the history each agent can use, you could manually retrieve the memory of a specific agent and decide which messages to use in a new agent run.
It might also work if multiple agents share the same memory config (same resourceId and same threadId). But that might cause problems if multiple agents are running in parallel and write into the same memory concurrently.
Reference: Agent.getMemory() | Agents | Mastra Docs v1 Beta
Mastra v1 Beta: Documentation for the
Agent.getMemory() method in Mastra agents, which retrieves the memory system associated with the agent.