Mastra is a TypeScript framework for building agents and workflows with persistent memory and evaluation. These exercises cover Mastra's runtime target, Agent vs. Workflow distinctions, the memory system with vector stores, tool execute context, and quality evaluation scorers.
0 / 5 completed
1 / 5
What is Mastra and what runtime does it target?
Mastra is a TypeScript agent framework from the team behind Gatsby. It targets Node.js environments with first-class integration for Next.js and other JS frameworks. It provides agents, workflows, tools, memory, and evaluation primitives in a type-safe TypeScript API.
2 / 5
In Mastra, what is the difference between an Agent and a Workflow?
Mastra Agents use an LLM to dynamically decide which tools to call and how to respond, enabling flexible reasoning. Workflows are deterministic, graph-based pipelines where you explicitly define steps and their execution order (sequential, parallel, or conditional), providing predictable control flow for complex multi-step operations.
3 / 5
How does Mastra's memory system work for agents?
Mastra's memory system provides persistent storage across sessions, combining a database (LibSQL/PostgreSQL) for message history with a vector store for semantic retrieval. Agents can recall relevant past interactions using similarity search, enabling long-term memory beyond the context window.
4 / 5
A developer defines a Mastra tool with execute: async ({ context }) => { ... }. What does context contain?
The context parameter in a Mastra tool's execute function contains the validated input arguments that the LLM passed when invoking the tool. The arguments are validated against the tool's Zod input schema before execute is called, ensuring type safety.
5 / 5
What does Mastra's agent evaluation feature provide?
Mastra's evaluation system provides scorers (metrics like answer relevance, faithfulness, tone) that evaluate agent outputs against test datasets. You can run evaluations as part of CI/CD to catch quality regressions when changing prompts, models, or tools, similar to unit tests but for LLM behavior.