Open Source AI Agent SDK Comparison 2026: LangGraph, Letta, Mastra, Agno, Pydantic AI, Ujex
For state-machine orchestration: LangGraph. For batteries-included framework + memory: Letta. For TypeScript-first opinionated: Mastra. For type-safe Python with function calling: Pydantic AI. For Phidata's successor: Agno. For substrate (email, memory, ingress, audit) underneath any of the above: Ujex. Different layers; usually you pick one of each.
"Best open source tools for building AI agents in 2026" lists usually conflate frameworks, runtimes, memory layers, and substrates. They're different layers. This post separates them, then ranks within each.
The four layers
| Layer | What it does | Examples |
|---|---|---|
| Framework | Agent loop, state machine, tool calls | LangGraph, Mastra, Agno, Pydantic AI |
| Runtime + framework | Framework + a place to run + persistence | Letta |
| Memory layer | Long-term memory, semantic search | Mem0, Zep, Ujex Recall |
| Substrate | Email, ingress, budgets, audit, mobile | Ujex (with subsystem-level alternatives) |
Most production agents pick one from each row. They compose.
Frameworks compared
LangGraph
State machine + checkpointer. Type-safe state transitions, streaming, replay, interruption. Apache-2.0. Maintained by LangChain Inc. The most flexible if you can map your agent to a graph.
from langgraph.graph import StateGraph
graph = StateGraph(MyState)
graph.add_node('plan', plan)
graph.add_node('execute', execute)
graph.add_edge('plan', 'execute')
Mastra
TypeScript-first. Opinionated structure: agents, workflows, tools, integrations. Built-in memory, observability hooks. Open-source, MIT.
Agno (formerly Phidata)
Python. Combines agent + memory + RAG + workflows in one library. Multimodal-first. Apache-2.0.
Pydantic AI
Type-safe Python with function-calling-first design. If you live in Pydantic-land, this fits naturally. MIT.
OpenAI Agents SDK
First-party from OpenAI. Streamed handoffs, tool calls, guardrails. Open-source MIT-style. Right when OpenAI is your primary model.
Runtime + framework
Letta (formerly MemGPT)
Three-tier memory (Core / Recall / Archival) with the agent loop included. Self-hostable Apache-2.0; managed Letta Code product also available. Right when you want batteries-included and the MemGPT model fits.
Memory layers
See Mem0 vs Letta vs Zep vs Ujex Recall for the comparison.
Substrate
The thing every agent needs that frameworks don't ship: real email, public webhook URL, spend cap, mobile approval, audit log. Ujex ships these as six composable subsystems with Apache-2.0 SDKs. Alternatives exist per-subsystem (AgentMail, Hookdeck, etc.); the bet of "all in one Firebase project" is what makes Ujex specific.
The matrix
| LangGraph | Letta | Mastra | Agno | Pydantic AI | Ujex | |
|---|---|---|---|---|---|---|
| Type | Framework | Runtime+FW | Framework | Framework | Framework | Substrate |
| Language | Python, TS | Python | TypeScript | Python | Python | Python, Go, TS |
| Memory built in | BaseStore primitive | 3-tier | Yes | Yes | No | Recall subsystem |
| Email built in | ✗ | ✗ | Integrations | ✗ | ✗ | Postbox subsystem |
| Ingress built in | ✗ | ✗ | ✗ | ✗ | ✗ | Ingress subsystem |
| Audit built in | ✗ | ✗ | Observability | ✗ | ✗ | Hash-chain |
| Budgets | ✗ | ✗ | ✗ | ✗ | ✗ | Governor |
| License | Apache-2.0 | Apache-2.0 | MIT | Apache-2.0 | MIT | Apache-2.0 SDKs |
Pick by use case
"Type-safe state machine, BYO everything"
LangGraph + your-favorite-memory + Ujex (substrate) + your model.
"Just give me an agent that works"
Letta. Batteries included. Self-host or managed.
"TypeScript only"
Mastra (framework) + @ujex/client (substrate). Same auth/data.
"Function-call-first Python"
Pydantic AI + Ujex.
"OpenAI is my primary model"
OpenAI Agents SDK + Ujex (or vendor each subsystem separately).
Migration between frameworks
The agent loop changes; the substrate doesn't. If you switch from LangGraph to Letta, your Ujex Postbox / Recall / Audit / Mobile setup is unchanged — the agent calls the same SDK from a different framework. That's the value of substrate-as-a-layer.
What "agent infrastructure setup" actually requires
Per the eight-vendors-or-one argument:
- Email — AgentMail or Postbox or Mailgun-on-top
- Memory — Mem0 / Letta / Zep / Recall
- Ingress — Cloudflare Tunnel / Hookdeck / Ingress
- Budgets — Governor / DIY middleware
- Mobile — Twilio + DIY / Mobile subsystem
- Audit — DIY append-only log / Audit subsystem
- Observability — Langfuse / LangSmith / Helicone (separate concern)
Pick one vendor or implementation per row. The math: 7 vendors, or Ujex + 1 observability tool.
FAQ
Can I run Letta on top of Ujex?
Yes — Letta as the agent runtime, Ujex for email + ingress + audit + mobile + budgets. Different layers.
Which framework has the best community in 2026?
LangGraph by raw activity. Letta is more focused; smaller but engaged. Mastra is growing fast in TypeScript.
Is OpenAI Agents SDK lock-in?
Less than you'd think — the SDK is open and provider-agnostic at runtime via litellm-style abstractions, but it's optimized for OpenAI's tool-calling and streaming.
What about CrewAI / Autogen?
Both alive. CrewAI is multi-agent role-based; Autogen is multi-agent conversation-based. Different shape from the single-agent frameworks above. Both work with Ujex as substrate.