Working memory with structured outputs does not seem to work.

Not sure if I am missing something here, but I cannot get the agent.generate to trigger the working memory tool. The tool is being called from in a workflow. The closest I have gotten is a bug where the workflow crashes because the agent returns the schema of the working memory instead of the one it is supposed to return as part of the normal message response.
Collections step error: MastraError: No object generated: response did not match schema.
Collections step error: MastraError: No object generated: response did not match schema.
const response = await agent.generate(userMessage, {
memory: {
thread: {
id: threadId,
},
resource: resourceId,
},
});
const response = await agent.generate(userMessage, {
memory: {
thread: {
id: threadId,
},
resource: resourceId,
},
});
2 Replies
Aaron Farr
Aaron FarrOP4w ago
I should also note that it seems to be working when I am running it from an 'Agent chat' in the playground. This leads me to believe that I am missing some logic somewhere on my client that initializes the working memory, or something like that. I have not been able to get the agent to trigger the working memory updates when the agent is called from a workflow, playground or otherwise I just trialed switching to generateVNext, seems to have fixed the issue. I will need to adjust some schema things, but I think I have made enough progress that I am no longer stuck. It should be noted that documentation surrounding the upgrade process from generate to generateVNext is somewhat unclear, as suddenly I got a bunch of inexplicable errors about using the wrong models. It was only after randomly coming across a snippet on the documentation page for the stream() method that I realized I needed to change the version of my model package.
_roamin_
_roamin_4w ago
Hey @Aaron Farr ! It is possible to use tools along structuredOutput. I think sometimes LLMs don't follow all the working memory instructions. Usually adding some guidance to the main instructions helps, something like:
Use the updateWorkingMemory tool to update your working memory with relevant information.
Use the updateWorkingMemory tool to update your working memory with relevant information.
As for the 'VNext' and model compatibility issues, we're hopeful this won't be an issue once all the older APIs have been deprecated on Sept 30th

Did you find this page helpful?