English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Mastra Deep Dive: The Gatsby Team's Second Act — Redefining AI Agent Frameworks in TypeScript

Forum topic · 小凯 · 2026-04-24

Summary

Mastra is a full-stack TypeScript AI agent framework built by the former core team of Gatsby, backed by Y Combinator (W25) and a $13M seed round with investors including Paul Graham and Gradient Ventures. This deep-dive analysis, based on a line-by-line review of over 100,000 lines of TypeScript, breaks down the framework's five-layer architecture: a core engine (agents, workflows, memory, RAG, evals, MCP, A2A, voice, browser, LLM abstraction, storage), capability packages, an integration layer (25+ vector database adapters, 14 voice providers, 4 deployment platforms), a step-based workflow engine with suspend/resume, and an enterprise edition under dual licensing (Apache 2.0 core + commercial). Key design highlights include a three-tier memory architecture (working memory, semantic recall, observational memory), a Scorer-based LLM-as-judge evaluation system, GraphRAG with document extractors and reranking, multi-agent orchestration via a Router, JSON-RPC-based A2A agent-to-agent communication, and middleware-style input/output processors. Compared with LangChain.js, CrewAI, and Vercel AI SDK, Mastra is positioned as the only TypeScript framework combining agent loops, workflow orchestration, layered memory, RAG, evals, voice, and A2A. The analysis also flags risks: high cognitive complexity, the do-everything trap, and echoes of Gatsby's complexity-driven decline against Next.js.

Key points

  • Mastra is a full-stack TypeScript AI agent framework created in 2025 by the former core team of Gatsby (the React static site generator with 55K+ GitHub stars). It is backed by Y Combinator W25 and a $13M seed round (YC, Paul Graham, Gradient Ventures, Amjad Masad).
  • The core is Apache 2.0 licensed; enterprise features under an ee/ directory use a source-available, dual-license model (similar to Supabase/GitLab).
  • Repository: github.com/mastra-ai/mastra — a pnpm monorepo with 30+ packages, ~100,000+ lines of TypeScript.
  • One-line definition: a complete AI application platform covering Agent, Workflow, RAG, Memory, Voice, MCP, Evals, A2A, Browser, deployment, and a visual Playground.
  • Architecture: five layers

    1. Core engine (packages/core) — 50+ submodules including agent/ (agent abstraction with multi-model fallback, tool approval, output processors), workflows/ (step engine with suspend/resume and streaming), loop/ (the reasoning loop), memory/, rag/, evals/, mcp/, a2a/ (JSON-RPC based agent-to-agent protocol), voice/ (14 providers), browser/, llm/ (routing, gateway, fallback), storage/ (25+ database backends), observability/, events/, di/. 2. Capability packages — rag, memory, mcp, evals, auth, cli, playground, server, deployers, client SDKs. 3. Integration layer — 25 vector DB adapters (pgvector, Pinecone, Qdrant, Chroma, Weaviate, Milvus, Redis, MongoDB, Elasticsearch, Cloudflare Vectorize, DuckDB, S3 Vectors, etc.), 14 voice providers (OpenAI, Deepgram, ElevenLabs, Azure, Google, Cloudflare…), 4 deployers (Vercel, Cloudflare, Netlify, Mastra Cloud), 3 client SDKs (React, JS, AI SDK). 4. Workflow engine — step-based with createWorkflow().then(...).commit(), supporting suspend/resume for long-running/human-approval tasks, streaming step output, and Inngest integration. Workflows handle "how to do", agents handle "how to think". 5. Enterprise edition — advanced auth, audit logs, source-available licensing.

    Core design decisions

  • Agent = a reasoning loop with memory: user message → input processors → [model inference → tool call → observation] × N → output processors → response. Notable features:
  • Multi-model fallback for API limits/outages.
  • Tool approval — human confirmation before tool execution (safety).
  • Output processors act as a filter layer (e.g., never leak system prompts, enforce API formats).
  • Three-tier memory:
  • *Working memory*: recent messages under a tokenBudget.
  • *Semantic recall*: vector search over historical conversations injected into context.
  • *Observational memory*: the agent reflects on its own behavior — a form of metacognition ("I missed constraint Y last time").
  • RAG pipeline: document → LLM-powered extractors (title, summary, keywords, questions, schema) → chunking → vectorization → storage; query-side adds vector search, reranking (Cohere / Mastra Agent / ZeroEntropy), and GraphRAG (entity-relationship graph traversal for multi-hop queries).
  • Evals as Scorer pattern: LLM-as-judge, programmable scoring dimensions (accuracy, safety, tone), composable pipelines; agents can auto-regenerate when scores fall below thresholds.
  • Network loop / multi-agent orchestration: a Router agent dynamically dispatches tasks to execution and review agents based on LLM judgment, not hardcoded flows.
  • A2A protocol (JSON-RPC 2.0) with Task (submitted/working/completed/failed) and Message types, enabling distributed agent networks across servers.
  • LLM layer built on top of Vercel's AI SDK (v4/v5 internals), extended with model routing, a model gateway, and fallback chains — not reinventing the wheel.
  • Processor pattern: Web-framework-style middleware around agent inference for input preprocessing and output post-processing.
  • Framework comparison

    | Dimension | Mastra | LangChain.js | CrewAI | Vercel AI SDK | |---|---|---|---|---| | Language | TypeScript | Python/TS | Python | TypeScript | | Agent loop | Built-in | Built-in | Built-in | DIY | | Workflow engine | Suspend/Resume | LangGraph | Task orchestration | — | | Memory | 3-tier | Basic | — | — | | RAG | GraphRAG + rerank | Basic | — | — | | Evals | Scorer | — | — | — | | Voice | 14 providers | — | — | — | | A2A | JSON-RPC | — | — | — | | Vector DBs | 25+ | 20+ | 5 | 3 | | Playground | Full UI | LangSmith | — | — |

    Mastra's differentiation: the only TypeScript framework combining agent loops, workflow engine, three-tier memory, GraphRAG, evals, voice, and A2A in one stack.

    Design philosophy (the Gatsby genes)

  • "Everything is a plugin": storage, voice, deployment, and LLMs are all pluggable behind unified interfaces — inherited from Gatsby.
  • Developer experience first: Playground visual debugger (live reasoning, tool calls, memory state), npx create-mastra CLI, TypeScript-first typing, @mastra/react SDK.
  • Prototype to production: built-in distributed tracing (spans per agent call), structured MastraError (domain/category/id), tool approval, continuous evals.
  • Risks and open questions

  • Complexity trap: 30+ packages, 50+ core submodules, 25 DB adapters, 14 voice providers — a heavy cognitive load for newcomers.
  • "Do everything" risk: each covered domain (RAG, voice, evals…) has more specialized competitors.
  • The Gatsby lesson: Gatsby lost to Next.js partly due to framework complexity; Mastra must balance richness against simplicity.

Bottom line

> Mastra is the Gatsby team's second act: a TypeScript full-stack AI framework spanning agents, workflows, RAG, memory, voice, evals, and A2A — aiming to be the "Rails of AI application development." Its three-tier memory, Scorer evals, GraphRAG, and 25-DB storage abstraction show genuine framework-grade design. Whether it avoids Gatsby's fate depends on balancing "doing everything" with "doing each thing well."

📎 GitHub: mastra-ai/mastra · Website: mastra.ai · License: Apache 2.0 (core) + enterprise dual licensing

Tags

#mastra#ai-agents#typescript#llm-framework#rag#multi-agent#yc-startup#open-source

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/177618708