How Memory Works
Memory is already enabled on the Theme Park agent. In this lesson, you'll look under the hood at what that actually means: why the model is still stateless between calls, and what Mastra is doing to make follow-ups work.
You'll trace a real follow-up prompt in Studio to see exactly what context the agent received, and look at lastMessages: the setting that controls how much recent conversation history gets included per call. Mastra persists messages to storage, then re-includes them on later turns so the model has what it needs.
This matters because memory is not magic. What you're really doing is context engineering: deciding what the model gets to see for each call. Understanding that makes it much easier to reason about agent behavior and debug it when something feels off.
"The model is still stateless. Mastra stores context, then includes it again in later calls."
— Guil Hernandez
Mentioned in the lessonDirect link to Mentioned in the lesson
Code:
Relevant Mastra docs:
Join the communityDirect link to Join the community
Ask questions:
- Discord — chat with other learners and the Mastra team
- Guil on LinkedIn — ask him questions directly
Follow Mastra: