Phase 14 · Lesson 18 of 54

Production Agent Runtimes — Fast Instantiation and Typed Workflows

A production agent runtime optimizes what prototyping frameworks ignore: instantiation cost, typed workflow surfaces, and a serving-ready backend. The 2026 pairing: Agno (Python) aims at microsecond agent instantiation and stateless FastAPI backends. Mastra ships agents, tools, workflows, unified model routing, and composite storage on the Vercel AI SDK substrate.

Lesson 18 of 54Learn~45 minutesPython, TypeScript

Before this: Lesson 1 of Phase 14 (Agent Loop), lesson 13 of Phase 14 (LangGraph)

On this page

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

LangGraph, AutoGen, CrewAI are framework-heavy. Teams that want "just the agent loop, fast, in my runtime" reach for Agno (Python) or Mastra (TypeScript). Both trade some of the framework-owned primitives for raw speed and a tighter fit to the surrounding stack.

The Concept

Agno

  • Python runtime, formerly Phi-data.
  • "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: stateless session-scoped FastAPI backend. Each request starts a fresh agent; session state lives in a DB.
  • Native multimodal (text, image, audio, video, file) and agentic RAG.

The speed targets matter when you have thousands of short-lived agents per second (chat fan-in, evaluation pipelines). They matter less when one agent runs for 10 minutes.

Mastra

  • TypeScript, built on Vercel AI SDK.
  • Three primitives: Agents, Tools (Zod-typed), Workflows.
  • Unified Model Router — 3,300+ models across 94 providers (March 2026).
  • Composite storage: memory, workflows, observability to different backends; ClickHouse recommended for observability at scale.
  • Apache 2.0 with ee/ directories under source-available enterprise license.
  • Server adapters for Express, Hono, Fastify, Koa; first-class Next.js and Astro integration.
  • Ships Mastra Studio (localhost:4111) for debugging.
  • 22k+ GitHub stars, 300k+ weekly npm downloads at 1.0 (Jan 2026).

Positioning

Neither is trying to be LangGraph. They compete on:

  • Language fit. Agno for Python-first teams; Mastra for TypeScript-first.
  • Runtime ergonomics. Agno = near-zero overhead; Mastra = integrated with the Vercel ecosystem.
  • Observability. Both integrate with Langfuse/Phoenix/Opik (Lesson 24) but Mastra Studio is first-party.

When to pick each

  • Agno — Python backend, many short-lived agents, strong perf requirements, FastAPI shop.
  • Mastra — TypeScript backend, Next.js / Vercel deploy, unified multi-provider model routing, Zod-typed tools.
  • LangGraph (Lesson 13) — when durable state and explicit graph reasoning matter more than raw speed.
  • OpenAI / Claude Agent SDK — when 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 is not the bottleneck.
  • Ecosystem lock-in. Mastra's Vercel-flavored integration is a plus on Vercel, a minus elsewhere.
  • Enterprise license confusion. Mastra's ee/ directories are source-available, not Apache 2.0. Read the licenses if you're planning to fork.
wb-runtime-spawn

Build It

This lesson is primarily comparative — no single code artifact would do both frameworks justice. See code/main.py for a side-by-side toy: a minimal "run an agent, stream the output, persist session" flow implemented twice (once Agno-shaped, once Mastra-shaped).

Run it:

python3 code/main.py

Two structurally different but functionally equivalent traces.

Use It

  • Agno — Python backend that needs speed and FastAPI shape.
  • Mastra — TypeScript backend with many providers and workflow primitives.
  • Both ship first-party observability hooks. Both integrate with Langfuse.

Ship It

outputs/skill-runtime-picker.md picks Agno, Mastra, LangGraph, or a provider SDK based on stack, latency budget, and operational shape.

Exercises

  1. Read Agno's docs. Port the stdlib ReAct loop (Lesson 01) to Agno. What disappeared? What stayed?
  2. Read Mastra's docs. Port the same loop to Mastra. What changed in tool typing (Zod vs nothing)?
  3. Benchmark: measure agent instantiation latency on your stack. Does Agno's 2μs matter to your workload?
  4. Design a migration: if you've been running CrewAI in Python, what breaks if you move to Agno?
  5. 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 permits source reading but restricts commercial use

Further Reading

Check yourself

Quick quiz

  1. Which language pairing does the lesson recommend for each runtime?

    1. Agno for TypeScript, Mastra for Python
    2. Both are Go-first
    3. Agno for Python, Mastra for TypeScript
    4. Both are Rust-first
    Show the answer

    C. Agno for Python, Mastra for TypeScript Agno is Python (FastAPI-shaped); Mastra is TypeScript (Vercel AI SDK-shaped).

  2. What is Agno's recommended production deployment shape?

    1. A long-lived stateful daemon
    2. A serverless cron worker only
    3. A stateless session-scoped FastAPI backend; each request starts a fresh agent and session state lives in a DB
    4. A WebSocket-only server
    Show the answer

    C. A stateless session-scoped FastAPI backend; each request starts a fresh agent and session state lives in a DB Stateless FastAPI per request; session state externalized to a DB.

  3. What are Mastra's three primitives?

    1. Node, Edge, State
    2. Plan, Worker, Solver
    3. Agents, Tools, Workflows
    4. Actor, Message, Inbox
    Show the answer

    C. Agents, Tools, Workflows Agents (LLM + role), Tools (Zod-typed), and Workflows are Mastra's three primitives.

  4. Roughly what agent-instantiation cost does Agno target per its docs?

    1. About 1 second and 1 GiB per agent
    2. About 2 microseconds with about 3.75 KiB per agent
    3. About 200 milliseconds and 100 MiB per agent
    4. About 10 minutes and 4 GiB per agent
    Show the answer

    B. About 2 microseconds with about 3.75 KiB per agent Agno's docs cite about 2 microseconds and about 3.75 KiB per agent.

  5. What does Mastra's Unified Model Router give?

    1. A vector DB layer
    2. A single client surface for thousands of models across many providers
    3. A graph checkpointer
    4. A queue for tool calls
    Show the answer

    B. A single client surface for thousands of models across many providers Mastra's Unified Model Router cites 3,300+ models across 94 providers.

  6. When is perf-for-perf's-sake the wrong reason to pick Agno?

    1. When using Langfuse
    2. When the workload is one slow agent call per request and overhead is not the bottleneck
    3. When using Python 3.13
    4. When deploying to AWS
    Show the answer

    B. When the workload is one slow agent call per request and overhead is not the bottleneck 2 microseconds matters at chat fan-in scale, not for a single slow call per request.

  7. What licensing surface should you read carefully before forking Mastra?

    1. There is no license file
    2. ee/ directories are source-available rather than Apache 2.0 and restrict commercial use
    3. All of Mastra is GPL
    4. Mastra requires CLA but no license review
    Show the answer

    B. ee/ directories are source-available rather than Apache 2.0 and restrict commercial use Mastra is Apache 2.0 except for ee/ which is source-available; check the restrictions before forking.

Questions people ask

What is Mastra?

Mastra is an open-source TypeScript framework for AI agents. It bundles agents, tools, workflows, model routing and storage, and builds on the Vercel AI SDK, which makes it a fit for web teams working in JavaScript.

How do you choose an AI agent framework?

Start with your team's main language and how much control you need. Check durability for long tasks, tracing, model choice, and community support. A smaller framework that fits your stack often beats a large one nobody wants to maintain.

Next lessonBenchmarks: SWE-bench, GAIA, AgentBenchPrevious: The Harness as a Library — Subagents and Session Store

Lessons from AI Engineering from Scratch by Rohit Ghumare and contributors, MIT license. Notes for owners by Lozo. License

Next step

Rather have it built for you?

Reading is optional. Tell me what's stuck and I'll build it into the business you already run.

  • A real conversation, not a pitch
  • You keep your accounts
  • Nothing sends without your yes