AgentOS vs LangGraph vs CrewAI vs Mastra: AI Agent Frameworks Compared
Building AI agents in 2026 means choosing between a growing number of frameworks. This comparison covers four production-ready options: AgentOS, LangGraph, CrewAI, and Mastra. Each targets different use cases and team profiles.
We built AgentOS, so we'll be upfront about where it excels and where alternatives might be a better fit.
Quick Comparison
| Feature | AgentOS | LangGraph | CrewAI | Mastra |
|---|---|---|---|---|
| Language | TypeScript | Python + JS | Python | TypeScript |
| GitHub Stars | ~90 | 24,800+ | 45,900+ | 22,300+ |
| npm/PyPI Downloads | Growing | 34.5M/mo | 5.2M/mo | 1.77M/mo |
| Architecture | GMI (cognitive entities) | State graphs | Role-based crews | Agents + workflows |
| Memory | Cognitive (8 mechanisms, Ebbinghaus decay) | Conversation + checkpoints | Short/long-term + entity (ChromaDB/SQLite) | Conversation + semantic + observational |
| LLM Providers | 16 built-in | Model-agnostic via LangChain | Model-agnostic | 94 providers via AI SDK |
| Guardrails | 6 packs (PII, injection, code safety, grounding, content policy, topicality) | Content moderation middleware | Basic output validation | None built-in |
| Multi-Agent | 6 strategies + emergent teams | State graph orchestration | Role-based crews + flows | Agent networks + workflows |
| Channels | 37 (Telegram, WhatsApp, Discord, Slack, etc.) | None built-in | None built-in | None built-in |
| Voice Pipeline | Full (STT + TTS + VAD + telephony) | None built-in | None built-in | None built-in |
| Personality | HEXACO 6-trait system | None | Role descriptions | None |
| Structured Output | Zod-validated with retry | Via LangChain | Basic | Via AI SDK |
| Deployment | npm install (self-hosted) | LangGraph Cloud ($0.001/node) | AMP Cloud/Factory (from $25/mo) | Serverless-first (Vercel, Cloudflare) |
| License | Apache 2.0 | MIT | MIT | Apache 2.0 |
Code Comparison: Same Task, Four Frameworks
A research agent that searches the web and answers a question.
AgentOS (TypeScript)
import { agent } from '@framers/agentos';
const researcher = agent({
provider: 'anthropic',
instructions: 'You are a research assistant. Search the web and cite sources.',
tools: ['web_search', 'deep_research'],
personality: { openness: 0.9, conscientiousness: 0.8 },
memory: { enabled: true, cognitive: true },
guardrails: { output: ['grounding-guard'] },
});
const answer = await researcher.text('What caused the 2008 financial crisis?');
10 lines. Personality, cognitive memory, web search, citation verification, and grounding guardrails are configured declaratively.
LangGraph (Python)
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
from langchain_community.tools import TavilySearchResults
model = ChatAnthropic(model="claude-sonnet-4-20250514")
tools = [TavilySearchResults(max_results=3)]
agent = create_react_agent(model, tools)
result = agent.invoke({
"messages": [{"role": "user", "content": "What caused the 2008 financial crisis?"}]
})
Straightforward. LangGraph inherits access to the LangChain tool ecosystem. No built-in personality, memory decay, or guardrails — those require additional middleware.
CrewAI (Python)
from crewai import Agent, Task, Crew
from crewai_tools import SerperDevTool
researcher = Agent(
role="Research Analyst",
goal="Find comprehensive, well-sourced information",
backstory="You are a thorough research analyst with 10 years of experience.",
tools=[SerperDevTool()],
)
task = Task(
description="What caused the 2008 financial crisis?",
agent=researcher,
expected_output="A detailed analysis with sources"
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()
The role/goal/backstory metaphor maps naturally to how humans think about team composition. CrewAI has the fastest path from zero to a working multi-agent prototype.
Mastra (TypeScript)
import { Agent } from '@mastra/core';
import { anthropic } from '@ai-sdk/anthropic';
const researcher = new Agent({
name: 'researcher',
model: anthropic('claude-sonnet-4-20250514'),
instructions: 'You are a research assistant.',
tools: { webSearch: mySearchTool },
});
const result = await researcher.generate('What caused the 2008 financial crisis?');
Clean TypeScript API. Mastra connects to 94 providers via the AI SDK and supports MCP servers for tool integration.
Architecture Deep Dive
AgentOS: Generalized Mind Instances
AgentOS models each agent as a Generalized Mind Instance (GMI) — a cognitive entity with working memory, personality traits, episodic/semantic/procedural memory stores, and a behavioral adaptation loop. This is fundamentally different from treating agents as stateless function calls with chat history appended.
The GMI manages:
- Working memory (7 ± 2 slots, based on Baddeley's model)
- Episodic memory — autobiographical events that decay via Ebbinghaus forgetting curves
- Semantic memory — durable facts extracted from conversations
- Procedural memory — learned patterns and preferences
- Prospective memory — future intentions and commitments
Eight cognitive mechanisms modulate memory behavior, each backed by published cognitive science:
| Mechanism | Effect | Source |
|---|---|---|
| Reconsolidation | Retrieved memories drift toward current mood | Nader, Schiller & LeDoux (2000) |
| Retrieval-Induced Forgetting | Retrieving one memory suppresses similar competitors | Anderson, Bjork & Bjork (1994) |
| Involuntary Recall | Random surfacing of old high-vividness memories | Berntsen (1996) |
| Metacognitive FOK | Feeling-of-knowing scoring for tip-of-tongue states | Hart (1965) |
| Temporal Gist Extraction | Old memories compressed to core assertions | Reyna & Brainerd (1995) |
| Schema Encoding | Novel input boosted, familiar patterns encoded efficiently | Bartlett (1932) |
| Source Confidence Decay | Agent inferences decay faster than direct observations | Johnson, Hashtroudi & Lindsay (1993) |
| Emotion Regulation | Reappraisal + suppression during consolidation | Gross (1998) |
No other framework implements these mechanisms. LangGraph, CrewAI, and Mastra store chat history. AgentOS agents remember.
LangGraph: Typed State Graphs
LangGraph models agent logic as a directed graph where nodes are computation steps and edges are transitions with conditional routing. State is typed and flows between nodes explicitly.
Key architectural strengths:
- Checkpointing: Built-in persistence via MemorySaver, PostgresSaver, or RedisSaver. Enables time-travel debugging — replay any past state
- Cycles: Unlike pure DAG frameworks, LangGraph supports loops (agent retries, iterative refinement)
- Sub-graphs: Compose large systems from smaller graphs. Each sub-graph has its own state schema
- Human-in-the-loop: Built-in interrupt points for human approval before continuing execution
The tradeoff is verbosity. A simple "search and answer" agent in LangGraph requires defining a state schema, creating nodes, wiring edges, and compiling the graph. For complex multi-step workflows with deterministic branching, that explicitness pays off. For simpler use cases, it's overhead.
CrewAI: Role-Based Teams
CrewAI uses a role-playing metaphor where each agent has a role, goal, and backstory. Tasks are assigned to specific agents. A Crew coordinates execution using one of three process types: sequential, hierarchical, or consensual.
In 2026, CrewAI added Flows — event-driven workflows using @start, @listen, and @router decorators. This gives CrewAI two complementary modes: autonomous crews for open-ended collaboration, and structured flows for deterministic pipelines.
Memory uses ChromaDB for short-term vector storage and SQLite3 for long-term persistence. Entity memory extracts and tracks key entities across conversations. The memory system is simpler than AgentOS (no decay, no reconsolidation, no personality modulation) but sufficient for many production use cases.
Mastra: TypeScript Workflows + AI SDK
Mastra is built on the Vercel AI SDK for model routing and adds a graph-based workflow engine with .then(), .branch(), and .parallel() primitives. Agent Networks enable LLM-powered routing between specialized agents.
Mastra's memory system has four tiers:
- Message history — standard conversation context
- Working memory — Zod-validated structured state persisted between turns
- Semantic recall — RAG over past conversations
- Observational Memory — automatic summarization at 30,000 tokens (5-40x compression, using background Gemini 2.5 Flash calls)
Mastra Studio provides a local web-based IDE for testing agents interactively — a developer experience feature no other framework matches.
Multi-Agent Comparison
| Capability | AgentOS | LangGraph | CrewAI | Mastra |
|---|---|---|---|---|
| Sequential execution | strategy: 'sequential' | Explicit edges | process: 'sequential' | .then() chains |
| Parallel execution | strategy: 'parallel' | Parallel branches | Via Flows | .parallel() |
| Debate/adversarial | strategy: 'debate' | Custom nodes | Not built-in | Not built-in |
| Review loops | strategy: 'review-loop' | Cyclic graphs | Via Flows | .branch() loops |
| Hierarchical | strategy: 'hierarchical' | Sub-graphs | process: 'hierarchical' | Agent Networks |
| DAG/graph | strategy: 'graph' with dependsOn | Native state graphs | Via Flows | Native graph engine |
| Shared memory | memory: { shared: true } | Shared state object | Shared crew memory | Working memory |
| Inter-agent messaging | AgentCommunicationBus | Via shared state | Task delegation | Network routing |
| Human-in-the-loop | HITL approval gates | Built-in interrupts | Not built-in | suspend()/resume() |
AgentOS provides 6 built-in strategies that cover the most common multi-agent patterns. LangGraph gives the most low-level control but requires you to implement each pattern from scratch. CrewAI's role-based metaphor is the most intuitive for non-technical stakeholders. Mastra's graph engine is clean and composable.
Safety and Guardrails
This is where the frameworks diverge most dramatically.
| Safety Feature | AgentOS | LangGraph | CrewAI | Mastra |
|---|---|---|---|---|
| PII redaction | 4-tier (regex + NLP + NER + LLM) | Third-party | Not built-in | Not built-in |
| Prompt injection defense | ONNX BERT classifiers | Third-party | Not built-in | Not built-in |
| Content policy | 8 categories, LLM rewrite/block | Third-party | Not built-in | Not built-in |
| Code safety | 25 OWASP regex rules | Not built-in | Not built-in | Not built-in |
| Grounding guard | NLI-based claim verification | Not built-in | Not built-in | Not built-in |
| Cost caps | CostGuard with hard limits | Not built-in | Not built-in | Not built-in |
| Security tiers | 5 levels (dangerous → paranoid) | Not built-in | Not built-in | Not built-in |
AgentOS ships 6 guardrail packs covering PII redaction, ML-based classifiers (toxicity, injection, jailbreak), topicality enforcement, code safety scanning, grounding verification, and content policy rewriting. Five security tiers (dangerous > permissive > balanced > strict > paranoid) control which tools and guardrails are active.
CrewAI has documented cost control issues: a single Gemini run reportedly cost $414, and a stop-sequence bug caused 10x cost overruns ($1.00 per call vs $0.10 expected). Neither CrewAI nor Mastra have built-in token budget caps.
LangGraph defers safety to middleware and the LangChain ecosystem. Guardrails exist as third-party integrations, not first-class features.
Deployment and Operations
| AgentOS | LangGraph | CrewAI | Mastra | |
|---|---|---|---|---|
| Install | npm install @framers/agentos | pip install langgraph | pip install crewai | npm install @mastra/core |
| Hosting | Self-hosted | LangGraph Cloud ($0.001/node) | AMP Cloud (from $25/mo) | Mastra Cloud (beta) / serverless |
| Serverless | Yes | No (not Vercel/CF compatible) | AWS Lambda patterns | Yes (Vercel, Cloudflare, Netlify) |
| Observability | OpenTelemetry native | LangSmith | AMP tracing | Langfuse, LangSmith, Sentry, OTel |
| Key rotation | Built-in (comma-separated env vars) | Not built-in | Not built-in | Not built-in |
Mastra has the strongest serverless story with first-class deployers for Vercel, Cloudflare Workers, and Netlify. AgentOS is self-hosted but runs anywhere Node.js runs. LangGraph requires its own cloud platform for hosted execution — it's not compatible with serverless platforms like Vercel or Cloudflare.
Unique Features Per Framework
Only in AgentOS
- HEXACO personality traits that modulate memory, retrieval, and response style
- 8 cognitive memory mechanisms with published neuroscience citations
- 37 channel adapters (Telegram, WhatsApp, Discord, Slack, SMS, and more)
- Full voice pipeline (STT, TTS, VAD) with telephony (Twilio, Telnyx, Plivo)
- Runtime tool forging — agents create new tools at runtime and promote them
- 88 curated skill definitions for agent capabilities
- API key rotation with automatic quota detection and failover
Only in LangGraph
- Time-travel debugging — replay any past checkpoint state
- LangSmith integration — production tracing and evaluation
- LangGraph Cloud — managed execution platform
- Sub-graph composition — hierarchical graph nesting
Only in CrewAI
- Role/goal/backstory metaphor — most intuitive agent definition
- Flows — event-driven workflow engine alongside autonomous crews
- 100,000+ certified developers through learn.crewai.com
- Enterprise AMP Suite with on-prem deployment option
Only in Mastra
- Mastra Studio — local web IDE for interactive agent testing
- Observational Memory — automatic 5-40x context compression
- 94 LLM providers through AI SDK integration
- MCP client and server — both sides of the Model Context Protocol
- Server adapters for Express, Hono, Fastify, Koa, Next.js, Astro
Decision Framework
Choose AgentOS if:
- Your agent needs consistent personality across thousands of conversations
- Memory behavior matters — agents should remember, forget, and reconsolidate
- You deploy to messaging channels (Telegram, WhatsApp, Discord, Slack)
- Safety is non-negotiable — PII redaction, injection defense, content policy enforcement
- Voice is part of the product
- You're building in TypeScript and want a cognitive runtime, not just an orchestration layer
Choose LangGraph if:
- You need complex workflows with explicit state management and conditional branching
- Your team writes Python and uses the LangChain ecosystem
- Time-travel debugging and checkpoint replay are important for your workflow
- You want a managed cloud platform (LangGraph Cloud) for hosted execution
Choose CrewAI if:
- You want the fastest path to a working multi-agent prototype
- The role-based team metaphor matches how your organization thinks
- Your team writes Python
- You need enterprise support with SLAs (AMP Suite)
- Community size matters — CrewAI has the largest tutorial ecosystem
Choose Mastra if:
- You're a TypeScript team deploying to serverless platforms (Vercel, Cloudflare)
- You need maximum LLM provider flexibility (94 providers via AI SDK)
- Mastra Studio's interactive testing experience appeals to your workflow
- You want MCP integration for connecting agents to external tools
- Next.js or React integration is a priority
When NOT to Use AgentOS
- You need the largest ecosystem. LangGraph/LangChain and CrewAI have 10-100x more community content, tutorials, and Stack Overflow answers. If you need to Google your way through problems, choose a framework with more documentation surface area.
- You're a Python shop. AgentOS is TypeScript-first. Use LangGraph or CrewAI.
- You need enterprise support today. CrewAI and LangChain offer enterprise tiers with SLAs. AgentOS is open-source with community support.
- You need serverless-first deployment. Mastra has purpose-built deployers for Vercel and Cloudflare. AgentOS runs on any Node.js host but doesn't have managed serverless deployment.
Getting Started with AgentOS
npm install @framers/agentos
import { generateText } from '@framers/agentos';
const { text } = await generateText({
provider: 'openai',
prompt: 'Explain quantum entanglement.',
});
console.log(text);
- Documentation — Getting started, API reference, architecture guides
- GitHub — Source code, issues, contributing
- Discord — Community chat and support
- npm — Package registry
Sources
- Speakeasy: Agent Framework Comparison (2026) — Benchmark data, DX scores, cost analysis
- Firecrawl: Best Open Source Agent Frameworks (2026) — GitHub stars, download metrics, deployment data
- GuruSup: Best Multi-Agent Frameworks in 2026 — Architecture comparison, decision framework
- LangGraph Documentation — State graphs, checkpointing, sub-graphs
- CrewAI Documentation — Crews, flows, memory, enterprise
- Mastra Documentation — Agents, workflows, studio, MCP
- AgentOS Documentation — GMI architecture, cognitive memory, guardrails
Framework features and star counts change. Check each framework's documentation for the latest information.
AgentOS is built by Manic Agency LLC / Frame.dev. See Wilds.ai for AI game worlds powered by AgentOS.
