Mastra tutorial: agent setup, memory and coding tools

Learn how Mastra builds TypeScript agents with Studio, evaluation datasets and local file access, plus how its observer and reflector memory system works.

Player not loading? Watch on YouTube

Mastra CTO Abhi Aiyer demonstrates a TypeScript framework for building agents, starting with a weather example in Mastra Studio. The walkthrough covers provider selection, tool calls and dynamic model routing through request context. The demo uses provider API keys; running the development interface locally does not establish that model inference runs on the same machine.

Studio exposes traces with model inputs, outputs and token usage. Aiyer then explains code-based scorers and LLM-as-judge evaluations, along with datasets built from recorded traces. Experiments rerun an agent against those inputs to check changes over time. He also describes storage interfaces that developers can extend for their own databases.

A longer section examines observational memory. Aiyer describes an actor, observer and reflector that compress conversation history into event-based observations. He reports benchmark results and a month-long coding session, which are claims from the presentation rather than independent tests. The live demonstration also encounters a missing API key for the memory process.

The final demos add a local filesystem, sandbox and skills to the weather agent, then introduce Mastra Code as an open source coding assistant built on the framework's harness abstraction. Aiyer explains that developers can deploy Mastra as a server or use it within an existing server application, making the session relevant to self-hosted agent infrastructure.