Skip to content
VDAI with VD

Phase 14 · Agent Engineering

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.

  • Learn
  • Python, TypeScript
  • 45 minutes
  • Before this: Phase 14 · 01 (Agent Loop), Phase 14 · 13 (LangGraph)

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.

Interactive figure coming later.

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

TermWhat people sayWhat 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

Code

  • main.py

    python phases/14-agent-engineering/18-agno-and-mastra-runtimes/code/main.pyOpen on GitHub ↗
  • main.ts

    npx tsx phases/14-agent-engineering/18-agno-and-mastra-runtimes/code/main.tsOpen on GitHub ↗

Take-away files

skill-runtime-picker.md

---
name: runtime-picker
description: Pick a production agent runtime (Agno, Mastra, LangGraph, provider SDK) for a given stack, latency budget, and operational shape.
version: 1.0.0
phase: 14
lesson: 18
tags: [agno, mastra, langgraph, runtime, selection]
---

Given a stack, latency budget, required primitives, and operational shape, pick a runtime.

Decision:

1. Python + FastAPI + thousands of short-lived agents per second -> **Agno**.
2. TypeScript + Next.js/Vercel + unified multi-provider -> **Mastra**.
3. Durable state, explicit graph, resume-on-failure -> **LangGraph** (Lesson 13).
4. Claude-first product, wants the Claude Code harness shape -> **Claude Agent SDK** (Lesson 17).
5. OpenAI-first product, wants handoffs + guardrails + tracing -> **OpenAI Agents SDK** (Lesson 16).
6. Multi-agent team, actor-model concurrency, fault isolation -> **AutoGen v0.4** / **Microsoft Agent Framework** (Lesson 14).
7. Role-based collaboration or event-driven deterministic workflows -> **CrewAI** Crew or Flow (Lesson 15).
8. None of the above -> direct API calls + the stdlib loop from Lesson 01.

Produce:

- A short decision document: stack, latency target, primitives needed, observed trade-offs.
- A minimal scaffold in the chosen runtime.
- A migration plan if another runtime is in use today.

Hard rejects:

- Picking Agno or Mastra purely on "performance" when the workload is one slow call per request. Performance is rarely the bottleneck.
- Picking a TypeScript runtime in a Python monorepo without a rationale. Mixed-language agent code is an operational tax.
- Picking LangGraph for stateless short tasks. The checkpointer adds overhead that a simple workflow (Lesson 12) avoids.

Refusal rules:

- If the user wants "all five runtimes, to compare," refuse. Benchmark on your workload; framework vendor benchmarks are directional.
- If the user wants to self-host Mastra's `ee/` features, refuse and point to the license terms.
- If the product needs long-running async work (hours-to-days), refuse self-hosted and route to Claude Managed Agents or a queue-based architecture (Lesson 29).

Output: decision doc + scaffold + README. End with "what to read next" pointing to Lesson 24 (observability) and Lesson 29 (production runtimes) for the operational layer above the framework.