Agno and Mastra: Production Runtimes
Agno (Python) and Mastra (TypeScript) are the 2026 production-runtime pairing. Agno aims at microsecond agent instantiation and stateless FastAPI backends. Mastra ships agents, tools, workflows, unified model routing, and composite storage on top of the Vercel AI SDK.
Learning Objectives
- Identify Agno's performance targets and when they matter.
- Name Mastra's three primitives — Agents, Tools, Workflows — and the supported server adapters.
- Explain why a stateless session-scoped FastAPI backend is the recommended Agno production path.
- Pick Agno vs Mastra for a given stack (Python-first vs TypeScript-first).
The Problem
Agno and Mastra are agent runtimes that keep the loop and drop most of the framework around it. Agno is Python, Mastra is TypeScript.
LangGraph, AutoGen, and CrewAI are framework-heavy: they own state, graphs, roles, and message passing for you. Plenty of teams don't want that. They want the agent loop, fast, inside the runtime they already deploy. Both of these give up some framework-owned primitives in exchange for speed and a tighter fit with the surrounding stack.
The Concept
Agno
Agno is a Python agent runtime, formerly Phi-data. Its pitch is "No graphs, chains, or convoluted patterns — just pure python."
- Performance targets from their docs: ~2μs agent instantiation, ~3.75 KiB memory per agent, ~23 model providers.
- Production path: a stateless, session-scoped FastAPI backend. Each request starts a fresh agent, and session state lives in a database.
- Native multimodal (text, image, audio, video, file) and agentic RAG.
The speed targets pay off when you run thousands of short-lived agents per second, as in chat fan-in or evaluation pipelines. They barely register when one agent runs for 10 minutes.
Mastra
Mastra is a TypeScript agent runtime built on the Vercel AI SDK. It has three primitives: Agents, Tools (Zod-typed), and Workflows.
- Unified Model Router: 3,300+ models across 94 providers (March 2026).
- Composite storage sends memory, workflows, and observability to different backends. ClickHouse is the recommended choice for observability at scale.
- Licensing is Apache 2.0, except the
ee/directories, which fall under a source-available enterprise license. - Server adapters for Express, Hono, Fastify, and Koa, plus first-class Next.js and Astro integration.
- Mastra Studio (localhost:4111) ships for debugging.
- 22k+ GitHub stars and 300k+ weekly npm downloads at 1.0 (Jan 2026).
Positioning
Neither one is trying to be LangGraph. They compete on three things:
- Language fit. Agno suits Python-first teams, Mastra suits TypeScript-first teams.
- Runtime ergonomics. Agno is near-zero overhead. Mastra is integrated with the Vercel ecosystem.
- Observability. Both integrate with Langfuse, Phoenix, and Opik (Lesson 24), but Mastra Studio is first-party.
When to pick each
- Agno: Python backend, many short-lived agents, strong performance requirements, a FastAPI shop.
- Mastra: TypeScript backend, Next.js or Vercel deploy, unified multi-provider model routing, Zod-typed tools.
- LangGraph (Lesson 13): durable state and explicit graph reasoning matter more than raw speed.
- OpenAI or Claude Agent SDK: you want the provider's productized shape (Lessons 16–17).
Where this pattern goes wrong
- Perf for perf's sake. Picking Agno because "2μs" sounds good, when the workload is one slow agent call per request. Overhead isn't your bottleneck there.
- Ecosystem lock-in. Mastra's Vercel-flavored integration is a plus on Vercel and a minus anywhere else.
- Enterprise license confusion. Mastra's
ee/directories are source-available, not Apache 2.0. Read the licenses before you plan a fork.
Build It
This lesson is comparative, so no single code artifact would do both frameworks justice. code/main.py is a side-by-side toy: one minimal flow (run an agent, stream the output, persist the session) implemented twice, once Agno-shaped and once Mastra-shaped.
Run it:
python3 code/main.py
You get two traces that are structurally different and functionally equivalent.
code/main.ts is the same comparison as a TypeScript port: a Mastra-shaped agent, tool registry, and workflow with a mocked LLM step, plus an Agno-shaped sketch for contrast.
Use It
- Agno: a Python backend that needs speed and a FastAPI shape.
- Mastra: a TypeScript backend with many providers and workflow primitives.
Both integrate with Langfuse, Phoenix, and Opik for observability, and Mastra also ships its own debugger, Mastra Studio.
Ship It
outputs/skill-runtime-picker.md picks Agno, Mastra, LangGraph, or a provider SDK based on your stack, latency budget, and operational shape.
Choose by language and deployment target first. If your backend is Python and already speaks FastAPI, Agno fits. If it's TypeScript on Next.js or Vercel, Mastra fits. That decision settles most of the question before any benchmark does.
Be skeptical of leading with the microsecond numbers. They matter at chat fan-in scale and almost not at all when each request makes one slow agent call. Run exercise 3 on your own stack and let the measurement decide whether instantiation cost is even a factor for you. And if you're considering a Mastra fork, read the ee/ license terms before you write any code.
Exercises
- Read Agno's docs. Port the stdlib ReAct loop (Lesson 01) to Agno. What disappeared? What stayed?
- Read Mastra's docs. Port the same loop to Mastra. What changed in tool typing (Zod vs nothing)?
- Benchmark: measure agent instantiation latency on your stack. Does Agno's 2μs matter to your workload?
- Design a migration: if you've been running CrewAI in Python, what breaks if you move to Agno?
- Read Mastra's
ee/license terms. What restrictions would affect an open-source fork?
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| Agno | "Fast Python agents" | Stateless session-scoped agent runtime |
| Mastra | "TypeScript agents on Vercel AI SDK" | Agents + Tools + Workflows + Model Router |
| Unified Model Router | "Multi-provider access" | Single client for 3,300+ models across 94 providers |
| Composite storage | "Multiple backends" | Memory/workflows/observability each to a different store |
| Mastra Studio | "Local debugger" | localhost:4111 UI for introspecting agents |
| Source-available | "Not OSS" | License lets you read the source but is not an open-source license like Apache 2.0 |
Further Reading
- Agno Agent Framework docs: performance targets, FastAPI integration
- Mastra docs: primitives, server adapters, Model Router
- LangGraph overview: the stateful-graph alternative
- Comet Opik: observability comparisons cited by Mastra integrations