SKILL PROCEDURE

Mastra

TypeScript framework for building AI agents, deterministic workflows, and RAG pipelines on a shared storage and observability layer. Use when choosing between an agent loop and a workflow graph, wiring memory or retrieval into an agent, picking a storage or vector backend, or deploying a Mastra app to a serverless target or standalone server.

mastraai-agentstypescriptworkflowsrag
BEGINNER GUIDE

Understand Mastra before using it

CATEGORY

Mastra is catalogued under AI and agents.

START HERE WHEN

Your work repeatedly involves the concepts tagged above. Open the full procedure below when the current task matches them.

Compare related skills

SKILLCATEGORYSHARED CONCEPTSEXPLANATION
MastraAI and agentsCurrent skillTypeScript framework for building AI agents, deterministic workflows, and RAG pipelines on a shared storage and observability layer. Use when choosing between an agent loop and a workflow graph, wiring memory or retrieval into an agent, picking a storage or vector backend, or deploying a Mastra app to a serverless target or standalone server.
AI SDKAI and agents
typescript
Vercel AI SDK — provider-agnostic TypeScript toolkit for building streaming AI applications and agents. Use when generating or streaming text with LLMs, wiring model providers (OpenAI, Anthropic, Google), implementing tool calling, producing structured output with Zod, building chat UIs with useChat, or composing multi-step agents with ToolLoopAgent. Published by HardGraph, a curated graph of provenance-backed knowledge for AI agents.
ComposioAI and agents
ai-agents
Composio — a tool-calling platform that sits between an LLM/agent framework and external apps, giving an agent connected tools, managed authentication, tool search, triggers, a sandboxed workbench, and an MCP bridge. Use when an agent needs to take real actions in 1000+ SaaS/developer apps (Gmail, GitHub, Slack, Notion, Linear, etc.) without hand-writing each integration, when you want OAuth/API-key auth handled per connected account, when you need the same tools reachable over Model Context Protocol, or when wiring tools into OpenAI, Anthropic, LangChain, Autogen, CrewAI, LlamaIndex, Mastra, or the Vercel AI SDK.
Assistant UIAI and agentsSame categoryassistant-ui — React components for building AI chat interfaces. Use when building a chat UI (thread list, message composer, markdown rendering, tool-call parts, streaming), wiring it to a model runtime (Vercel AI SDK, LangChain, custom), using the CLI to scaffold and add components, adapting a shadcn/Radix/Base UI style, or running it on web, React Native, or the terminal. Published by HardGraph, a curated graph of provenance-backed knowledge for AI agents.

Mastra

Mastra separates two things that get conflated in most agent frameworks: an agent (an LLM given tools and let loose to decide what to call, in what order) and a workflow (a typed, deterministic step graph you control, with branching, suspend/resume, and retries). Both can call tools and both can be composed with each other — a workflow step can invoke an agent, and an agent can be handed a workflow as a callable tool. The mistake worth avoiding is using an agent where you actually want guaranteed ordering and durability, or a workflow where you actually want the model to decide the next action; both compile and run, only one gives you the reliability you meant to build.

Storage is a foundational choice, not a config detail

Agent memory, workflow snapshots, vector embeddings, and eval traces all sit on the same storage abstraction. The default local backend is a file-based LibSQL database — fine for development, wrong for anything with concurrent writers or that needs to survive a redeploy. Because workflow suspend/resume persists serialized state through this same layer, swapping storage later means migrating live snapshots, not just changing a connection string. Decide the production backend (Postgres, Turso, or another supported store) before shipping a workflow that suspends, not after.

Memory and RAG are not the same subsystem

Conversation memory (working memory, message history, semantic recall over past turns) and RAG (retrieval over an external knowledge base) both use a vector store, and both get lumped together as "give the agent context." They have different freshness, ownership, and eviction concerns — memory belongs to a thread/user, a knowledge base belongs to the document corpus. Treating one config as the other tends to leak unrelated conversation history into document retrieval or vice versa.

Deployment target shapes what a workflow can do

A Mastra app can run as a standalone Node server or be built for a specific serverless deployer (Vercel, Cloudflare, Netlify, and others). Serverless targets impose execution-time and statefulness limits that a long-running workflow with suspend/resume can violate silently until it hits them in production.

What to verify rather than recall

This framework ships fast. Treat these as unverified until checked against the mirrored corpus: exact @mastra/* package and CLI versions, the deployer package name and its platform-specific constraints, which vector-store adapters are currently supported, and the Mastra constructor / config keys in use — these have moved across recent releases.

Hardgraph / curated knowledge for agents.

STATIC EXPORT · CANONICAL SOURCE