Skip to main content
Back to blog
Enterprise AI

Choosing an agent framework: LangChain vs LangGraph vs CrewAI vs PydanticAI vs Mastra vs Vercel AI SDK

Nolan Sullivan

Nolan Sullivan

Published · 36 min read

Choosing an agent framework: LangChain vs LangGraph vs CrewAI vs PydanticAI vs Mastra vs Vercel AI SDK

The right agent framework speeds up prototyping, keeps your architecture clean, and gives you a deployment path that fits your runtime from day one. Picking the wrong framework creates technical debt that compounds quietly and can eventually stall your team.

To help inform your decision, this comparison evaluates five code-first agent frameworks, two SDKs, and one low-code platform:

  • LangChain
  • LangGraph
  • CrewAI
  • PydanticAI
  • OpenAI Agents SDK
  • Mastra
  • Vercel AI SDK
  • n8n

Versions, prices, and GitHub stars are current as of November 2026. An earlier version of this guide also covered Vellum, which has since pivoted and is shutting down its platform (see What happened to Vellum). We also briefly introduce three newer options in Other frameworks worth a look.

We compare these frameworks using the following five criteria:

  • Developer experience (DX)
  • Agent capabilities
  • Context and memory management
  • Deployment and hosting
  • Security and compliance

What is an agent?

An agent is a loop. It is an LLM that receives a prompt, decides what to do next (for example, call a tool, ask a clarifying question, or return a final answer), executes that action, observes the result, and repeats. Unlike a single LLM call, an agent can take many steps, and it keeps looping until the task is done or it hits a stop condition, such as a maximum number of iterations.

Four properties define agents:

  • Tool use: The agent decides when and how to invoke external functions, such as conducting a search, querying a database, or calling an API.
  • Memory: The agent’s state can persist within a session, across sessions, or both.
  • Planning: More sophisticated agents decompose goals into subgoals, spawn subagents, or check their own work.
  • Autonomy: The agent runs multiple steps without a human approving each one.

Do you need a framework?

An agent framework is a library or SDK that gives you the building blocks for agents, such as an agent loop, tools, handoffs, memory, and tracing. Deployment and management usually come from separate hosted products.

First, assess whether you need a framework.

  • If your agent calls two or three tools in a linear flow, skip the heavy frameworks: A lightweight SDK’s built-in tool loop is enough, such as the OpenAI Agents SDK or the Vercel AI SDK’s ToolLoopAgent (or generateText with stopWhen: isStepCount(n), called stepCountIs before AI SDK 7). When you have simple requirements, chains, nodes, crews, and runners tend to add friction you don’t need.
  • If your agent has unusual requirements, consider building your own thin layer: Unusual orchestration requirements, strict latency budgets, and non-standard memory architectures are often cleaner with a thin custom layer than with a framework you are fighting.
  • If your team and agent fall somewhere in the middle, that’s where a framework earns its keep: Agent frameworks work well when you have human-in-the-loop workflows, multi-agent coordination, or consistent tool schemas across a large codebase, especially if you need durable execution that survives crashes or built-in tracing.

Durability and approvals no longer require a heavy framework, though. AI SDK 7 adds agent-level tool approvals and durable agents through WorkflowAgent, and the OpenAI Agents SDK has built-in human-in-the-loop, sessions, and tracing, plus durable execution through Temporal.

The ecosystem at a glance

The eight options compared in this guide fall into two categories.

Code-first frameworks

These frameworks, in addition to the OpenAI Agents SDK and Vercel AI SDK, give you libraries and primitives for building agents in Python or TypeScript:

  • LangChain
  • LangGraph
  • CrewAI
  • PydanticAI
  • Mastra

You control orchestration logic, memory, and deployment, though several also offer optional managed hosting, such as LangSmith, Mastra Platform, and CrewAI AMP.

Hybrid frameworks

This category pairs a visual builder with code options:

  • n8n

n8n combines its visual editor with JavaScript and Python Code nodes, a public REST API, and the official @n8n/workflow-sdk TypeScript SDK for writing workflows as code. It’s a strong choice when non-technical stakeholders need to build or maintain workflows.

Speakeasy AI Control Plane

The Speakeasy AI Control Plane is a single layer that connects every AI agent (Claude, ChatGPT, Cursor, Copilot, internal agents) to every system that matters (SaaS tools, internal APIs, databases) and governs every prompt, response, and tool call with identity, policy, and observability built in. Internal APIs are turned into managed MCP servers from an OpenAPI spec, with no custom integration work per tool.

Speakeasy works with every MCP-compatible client, so whether you use an SDK, a code-first framework, or a hybrid framework, the AI Control Plane can help you organize the tools your agent can access.

LangChain

LangChain is an open-source agent framework for Python and JavaScript/TypeScript with over 1,000 model and tool integrations. It has the highest download volume in this comparison, with about 170 million PyPI downloads a month. The October 2025 v1.0 release added a simplified create_agent primitive, an API stability commitment, and a middleware layer for summarization, PII detection, and human-in-the-loop patterns.

Developer experience

LangChain’s strongest selling point is breadth. It is model-agnostic, builds a working agent in a few lines with create_agent, and has a stable 1.x API, making it fast for standard use cases. The LangChain Expression Language (LCEL) pipe operator still exists in langchain-core, but legacy chains have moved to the langchain-classic package.

If your framework requirements leave the standard path, you encounter its limits.

  • Abstraction depth hurts debuggability: When something breaks, you debug LangChain’s internals, not your own logic. In 2024, before v1.0, Octomind’s engineering team hit this limit directly: LangChain’s abstractions meant it often wasn’t easy or possible to write the lower-level code they needed.
  • Lowest DX score in the category: In a 90-day Nextbuild benchmark, LangChain scored 5/10 for developer experience, the lowest among five frameworks tested. PydanticAI scored 8/10.
  • Historical instability leaves residue: Prior to v1.0, breaking changes earned LangChain a reputation for churn. The v1.0 release moved legacy APIs into langchain-classic, but outdated tutorials built on pre-v1 APIs still slow down onboarding.

LangChain v1.0 is a better framework than its reputation suggests, and the ecosystem is unmatched. However, if you prioritize type safety and debuggability over integration coverage, PydanticAI and the OpenAI Agents SDK are sharper tools for the job.

Agent capabilities

LangChain runs a Reasoning and Acting (ReAct)-style tool-calling loop: the LLM picks a tool, executes it, observes the result, and repeats until it produces a final answer.

It is the right choice for:

  • Single-agent, linear tool-calling workflows: LangChain’s integration catalog includes many ready-made tools you can hand to create_agent.
  • Tool variety: It connects to MCP servers through the official langchain-mcp-adapters package, on top of its native integrations.
  • Rapid prototyping: The docs cover most common patterns.

It is the wrong choice for:

  • Cyclic or branching workflows: Use LangGraph for anything requiring cycles, persistent state, or durable execution.
  • Role-based multi-agent systems: Unlike CrewAI, LangChain has no role-based abstractions. Its docs describe multi-agent patterns such as subagents-as-tools and handoffs, but you write more of the coordination logic yourself.
  • Custom durable workflows: create_agent runs on the LangGraph runtime and accepts a checkpointer that persists thread state, so basic crash recovery works. For anything more, drop down to LangGraph or add Temporal.

Context and memory

LangChain’s legacy API shipped eight memory classes (buffer, windowed, token-limited, summarized, and others), which have been deprecated since v0.3.1 and now live in the langchain-classic package. In LangChain v1, short-term memory is agent state persisted by a checkpointer passed to create_agent (database-backed in production). You manage context growth by trimming or deleting messages, or by adding SummarizationMiddleware.

The drawback is that compression isn’t automatic. A v1 agent with only a checkpointer keeps the full message history, as does the legacy ConversationBufferMemory that’s still common in tutorials. Both work fine in development, but on long conversations the history eventually exceeds the model’s context window, and the provider rejects the request.

LangChain requires you to pick a memory strategy deliberately. By contrast, Mastra’s Observational Memory compresses history automatically once you enable it.

Deployment and hosting

LangServe is deprecated, and its GitHub repository was archived in May 2026. LangSmith Deployment (renamed from LangGraph Platform in October 2025) is now the recommended path. It provides persistence, human-in-the-loop pausing, cron jobs, and background processing across cloud, bring-your-own-cloud (BYOC), hybrid, and self-hosted topologies. It doesn’t run on Vercel Functions or Cloudflare Workers, so teams on those platforms should use Mastra or the Vercel AI SDK instead.

The framework itself is MIT licensed and free. LangSmith plans and pricing are covered in the LangGraph section below.

Security and compliance

The open-source framework has no authentication layer, so self-hosted apps typically implement auth themselves, for example, with FastAPI. LangSmith Deployment adds custom authentication and authorization for agent APIs, plus Agent Authorization (in beta). The v1.0 middleware layer adds built-in PII detection, human-in-the-loop approval, and call limits. LangSmith’s certifications are covered in the LangGraph section.

LangGraph

LangGraph is a lower-level runtime that LangChain now runs on internally. If LangChain’s abstractions are too high, LangGraph is the layer below them, not an alternative ecosystem. It is MIT licensed, at v1.2.20, with about 44,700 GitHub stars and roughly 44.8 million monthly PyPI downloads.

Developer experience

In LangGraph’s Graph API, you build an agent with a StateGraph builder: you add nodes, add edges, compile, and invoke. State is usually a TypedDict, though Pydantic models and dataclasses also work, and a Functional API (@entrypoint and @task) skips the graph builder. The model is explicit and verbose by design.

The learning curve is steep, its stack traces run deep, and the documentation you need is split across the LangGraph, LangChain, and LangSmith sections of the LangChain docs. If you want convenience, use CrewAI. If you want control, use LangGraph.

Agent capabilities

LangGraph models agents as stateful graphs with typed state, explicit cycles, and durable execution.

It is the right choice for:

  • Cyclic agent loops: LangGraph supports cycles and conditional edges natively, so agents can iterate until an exit condition is met. A configurable recursion_limit stops runaway loops.
  • Crash-proof execution: With a persistent checkpointer, such as Postgres or Redis, LangGraph saves state at every super-step. Agents can then survive server restarts and replay from any prior checkpoint.
  • Human-in-the-loop workflows: You can pause mid-run by calling interrupt() inside a node, then resume with Command(resume=...).
  • Time-travel debugging: Replay or fork execution from any prior checkpoint in LangSmith Studio or through the Agent Server API.
  • Multi-agent coordination at scale: Subgraphs, langgraph-swarm, and RemoteGraph (for cross-network agent calls) support larger systems.

It is the wrong choice for:

  • Role-based agent abstractions: CrewAI ships roles, goals, backstories, and delegation as primitives. LangGraph requires you to model all four explicitly as nodes and state.
  • TypeScript teams: TypeScript-native frameworks like Mastra have lower setup overhead and ship built-in deployers for Vercel, Netlify, and Cloudflare.
  • Serverless environments: LangSmith Deployment runs on LangChain’s cloud or your own Kubernetes, not on Vercel or Cloudflare Workers. The LangGraph.js library does run on Cloudflare Workers and Vercel Edge, but durable checkpoints need an external database.

Context and memory

State is a shared schema, and nodes return partial updates that reducers merge. InMemorySaver checkpoints every super-step once you pass it to compile(checkpointer=...), but it’s RAM-only and meant for development. For production, use PostgresSaver or RedisSaver, plus the Store interface and LangMem for long-term, cross-thread memory.

There are two drawbacks to using LangGraph in production:

  • It doesn’t have native token budget management: You trim messages yourself, use LangMem summarization, or build on create_agent, whose SummarizationMiddleware summarizes older messages as history nears a token threshold. Context bloat will silently degrade your agent if you are not deliberate about it.
  • Large state objects bloat checkpoints: Persistent savers store channel values by version, so unchanged channels aren’t duplicated, but large values still add up. Offload large file contents to external storage rather than keeping them in state.

Deployment and hosting

LangSmith Deployment (called LangGraph Platform until its October 2025 rename) manages scaling, persistence, streaming, and cron scheduling. A July 2026 repricing replaced per-node charges with billing for the resources you use. The plans are:

  • The free Developer plan doesn’t include deployments.
  • The Plus plan costs $39 per seat per month and includes 10,000 base traces and one small serverless deployment. Additional deployments are metered in LangSmith Units (1 LSU = $1), for example, 0.0675 LSU per vCPU-hour of runtime compute. Five Plus seats come to $195 per month before trace overages, deployment usage, and LLM costs.
  • The Enterprise plan offers cloud, hybrid, and self-hosted options at custom pricing. Self-hosted and hybrid deployments are Enterprise-only.

Security and compliance

LangChain’s SOC 2 Type II attestation, ISO 27001 certification, and HIPAA and GDPR compliance cover the hosted LangSmith platform, including Deployment. The open-source libraries have no certification of their own. If you need a HIPAA business associate agreement (BAA), confirm the terms with LangChain. Deployments can run in GCP US, EU, and APAC regions or on AWS us-east-2, but billing data is stored in the US only.

Plus includes Google and GitHub single sign-on (SSO), and Enterprise adds custom SSO, role-based access control (RBAC), and attribute-based access control (ABAC).

CrewAI

CrewAI says it is used by 65% of the Fortune 500, and its case studies include PwC and IBM. The open-source repo has more than 60,000 GitHub stars and ships near-daily releases. Its role-based mental model mirrors how many teams already organize work.

Developer experience

CrewAI lets you set up a crew, a group of agents that work together to accomplish tasks, in a few lines of code.

  • Each agent has a role, goal, and backstory.
  • Each task has a description and expected output.
  • Flows (@start, @listen, and @router) add event-driven orchestration.

Its limitations appear during debugging:

  • Black-box abstractions: When something goes wrong, it can be hard to see what the framework did on your behalf, and callbacks are a recurring pain point (for example, Task callbacks declared in tasks.yaml that never attach). AMP’s tracing and OpenTelemetry support, included on the free Basic plan, closes some of this gap.
  • Complex conditional logic: Flows help, but for non-linear branching, LangGraph’s graph-based approach is more flexible.

CrewAI offers one of the fastest paths from idea to working multi-agent prototype, but the path from prototype to debuggable production system is slower.

Agent capabilities

With CrewAI, you assign each agent a role and a goal. If you enable allow_delegation (it’s off by default) or use a hierarchical process, agents can also delegate tasks to one another.

It is the right choice for:

  • Role-based multi-agent systems: You define agents as first-class primitives and wire them into sequential or hierarchical crews with a single configuration block.
  • Deterministic control when needed: When agent delegation is too unpredictable, Flows let you define event-driven steps and branches explicitly.
  • Broad integration coverage: CrewAI supports over 20 LLM providers (native SDKs for OpenAI, Anthropic, Gemini, Azure, Bedrock, and Snowflake Cortex, and LiteLLM for the rest), a library of 40+ built-in tools, and MCP servers through the agent’s mcps field.

It is the wrong choice for:

  • Hierarchical crews at scale: Delegation in hierarchical crews is a known reliability issue, with reports of managers failing to delegate to workers or picking the wrong agent.
  • Deep debugging: CrewAI’s abstractions can make it hard to trace what happened when an agent produces the wrong output.
  • Cost-sensitive workloads: CrewAI has no built-in token budget, only iteration, time, and rate limits, and multi-agent runs add up quickly.

Context and memory

CrewAI ships a unified Memory class that replaces the separate short-term, long-term, entity, and external memory types with a single API (remember, recall, and forget). It uses an LLM to infer memory scopes, ranks recall by semantic similarity, recency, and importance, and stores data in LanceDB by default. Because an LLM analyzes content on each save, memory adds its own token cost.

Like LangGraph, CrewAI has no built-in token budget cap, which makes token cost a serious production risk, especially as running three or four agents in sequence multiplies the number of LLM calls per turn. Set max_iter (default 20), and optionally max_execution_time and max_rpm, before deploying, and verify costs against your LLM provider’s dashboard. For example:

Deployment and hosting

CrewAI Agent Management Platform (AMP) offers two hosted paths:

  • AMP Cloud (managed SaaS)
  • AMP Factory (self-hosted on your infrastructure, on-prem or in your own VPC, via Kubernetes)

Alternatively, you can self-host the open-source library, which has AWS-documented Lambda deployment patterns.

The framework is MIT licensed and free. The real cost is platform fees and LLM API spend. AMP pricing has a free Basic plan (50 executions per month) and a custom-priced Enterprise plan. We recommend modeling token costs before committing, because using multiple agents in sequence multiplies call counts, memory embeds, and overhead.

Security and compliance

CrewAI is SOC 2 Type II and HIPAA compliant. It provides PII detection, audit logs, and secret manager integrations, and AMP Factory keeps data within your infrastructure. The Enterprise plan adds SSO via SAML 2.0 and OAuth 2.0/OIDC, plus RBAC.

PydanticAI

PydanticAI is a Python agent framework from the Pydantic team, which now describes it as “the Python AI SDK.” It offers full type safety and automatic LLM output validation against Pydantic models. v2.0 went stable in June 2026, adding a new core primitive, capabilities, which bundle tools, hooks, instructions, and model settings. The latest release is v2.66.0, and v1.x still receives patches. PydanticAI is a production-ready alternative to LangChain for teams that prioritize type safety over ecosystem breadth.

Developer experience

A hello-world agent takes about five lines. Tools are decorated Python functions, and typed dependencies are injected at run time. In the Nextbuild benchmark, PydanticAI scored 8/10 for developer experience, the highest among five frameworks tested, and its type system caught 23 bugs during development that Nextbuild says would have reached production with LangChain.

The tradeoff is ecosystem size. PydanticAI has about 21,100 GitHub stars and 5.4 million monthly PyPI downloads, compared with about 149,000 stars and 170 million monthly downloads for LangChain, so third-party integrations and community resources are thinner. The gap is narrowing: the official Pydantic AI Harness, launched in July 2026, ships nearly 40 capabilities, and a third-party capability ecosystem is growing around it.

Agent capabilities

PydanticAI is built around single agents, but it supports several multi-agent patterns: you can register one agent’s run method as a tool inside another, let the Harness SubAgents capability automate that delegation, or orchestrate agents as nodes in a pydantic-graph state machine.

It is the right choice for:

  • Type-safe single-agent workflows: It automatically validates LLM outputs against Pydantic models.
  • Token budget control: Usage limits cap requests, input tokens, output tokens, total tokens, tool calls, and cost in USD. You pass them to each run, so budget controls sit right next to the agent call.
  • Standard interoperability: PydanticAI has built-in MCP support, plus AG-UI, Vercel AI, and ACP interfaces. A2A moved out of core in v2.0 and now lives in the separate fasta2a package.

It is the wrong choice for:

  • Role-based multi-agent systems: PydanticAI has no role or goal abstractions, so you assemble team structures yourself from delegation and graph-based control flow.
  • Agent handoffs: PydanticAI doesn’t have built-in handoff lists between agents, so architectures that depend on OpenAI-style handoffs need extra work.

Context and memory

PydanticAI is stateless by default. Each agent.run() is isolated unless you pass history back in explicitly. Storage is still your own database, but core now provides Conversation objects and a ConversationStore abstraction with conflict detection and forking. The Harness adds step-level snapshots and cross-session Memory.

For durable execution, the framework officially supports nine engines, including Temporal, DBOS, Prefect, Restate, and AWS Lambda.

Deployment and hosting

PydanticAI is a standard Python library that runs in your own process, so it works on most Python hosts, including serverless platforms like AWS Lambda, Google Cloud Functions, and Azure Functions. There is no PydanticAI-specific managed hosting, though AWS teams can use Amazon Bedrock AgentCore.

In the 90-day Nextbuild benchmark, PydanticAI’s costs were $390 in total, all of it infrastructure. CrewAI cost $1,088, but Nextbuild ran it on CrewAI’s paid tier with cloud orchestration enabled, so part of that gap reflects licensing rather than framework efficiency. Lock-in risk is low: PydanticAI is MIT licensed, model-agnostic, and built on OpenTelemetry throughout.

Security and compliance

PydanticAI has no built-in auth or RBAC. Since July 2026, the official Harness has shipped Guardrails, which can block, redact, retry, or require approval for inputs, tool calls, tool results, and outputs, and a Prompt Injection Defender that checks tool results for indirect prompt injection. Beyond those capabilities, security is enforced through code:

  • Type safety prevents data integrity bugs
  • Dependency injection gives tools access to credentials and clients without exposing them to the model
  • Output validation blocks malformed data from triggering downstream actions
  • Human-in-the-loop tool approval prevents dangerous operations

The open-source library carries no compliance certification itself, but Pydantic’s enterprise offering (Logfire and the AI Gateway, cloud or self-hosted) lists SOC 2 Type 2 and HIPAA compliance, with BAAs available.

OpenAI Agents SDK

OpenAI shipped the Agents SDK in early 2025 as a minimal Python abstraction, with Agent and Runner classes, tools, handoffs, guardrails, and sessions. It now has a TypeScript port and over 30,500 GitHub stars, and it is at v0.24.0. If you’re upgrading from an early-2026 release, check the changelog for breaking changes.

Developer experience

A working agent is only four lines, and you can learn the core primitives in an afternoon, although newer features like sandbox agents and realtime take longer to master. Tracing is enabled by default and displayed in the OpenAI dashboard, so for most teams the Agents SDK is faster to debug out of the box than a framework like LangChain, which requires LangSmith configuration. The exception is organizations under Zero Data Retention (ZDR), for which tracing is unavailable. The ceiling is provider lock-in: hosted tools are zero-infrastructure and excellent, but bound to OpenAI models.

Agent capabilities

The SDK runs an imperative Runner loop where handoffs are a first-class primitive. You define handoffs=[agent_b, agent_c], and the LLM decides when to delegate.

Since April 2026, the SDK also supports long-horizon Sandbox Agents: a harness with filesystem, shell, and apply-patch tools, skills, and built-in sandbox providers (such as Cloudflare, Daytona, E2B, Modal, and Vercel) with snapshotting and rehydration. Sandbox agents are available in both the Python and TypeScript SDKs.

The framework can help you:

  • Build handoff chains with minimal wiring: agent.as_tool() wraps any agent as a callable tool, and handoffs=[] is the simplest multi-agent configuration.
  • Access tools without setup overhead: The Agents SDK provides some of the best zero-infrastructure hosted tools in this comparison, such as WebSearchTool, CodeInterpreterTool, ImageGenerationTool, and HostedMCPTool.
  • Integrate MCP servers as native tool sources: MCP server integration doesn’t require additional adapters.

However, the framework can’t help you:

  • Build graph-based orchestration: LangGraph and Mastra’s .branch() handle complex state machines. This SDK is designed for handoff chains, agents-as-tools, and long-horizon sandboxed agents.
  • Declare parallel workflows: The SDK has no declarative parallel node. You can run agents concurrently with asyncio.gather, but you orchestrate this in code.
  • Model role-based agent systems: CrewAI’s roles, goals, and delegation are purpose-built for team-style coordination.
  • Use hosted tools on non-OpenAI models: WebSearchTool, FileSearchTool, and Code Interpreter are OpenAI-only.

Context and memory

Sessions are opt-in by design: without a session, the SDK doesn’t persist history automatically (you can still chain turns with previous_response_id or result.to_input_list()), which forces explicit state decisions. Built-in session backends such as SQLiteSession, RedisSession, SQLAlchemySession, and OpenAIConversationsSession cover most persistence needs. For long-running agents, the docs list four durable execution integrations: Dapr, Temporal, Restate, and DBOS. Sandbox agents can resume in a fresh container from their last snapshot, but for general agents there’s nothing like LangGraph’s native checkpointing.

Deployment and hosting

The SDK runs as a standard Python library, so it works on serverless platforms like Lambda, Azure Functions, and Google Cloud Functions. OpenAI doesn’t host SDK apps, but it offers hosted building blocks such as AgentKit.

It is MIT licensed with no SDK surcharge. You pay standard OpenAI per-token pricing plus additional costs per hosted tool call. Your lock-in risk is low at the SDK level and moderate if you rely on hosted tools or the Conversations API.

Security and compliance

The Agents SDK includes the EncryptedSession wrapper, which handles encrypted storage, and works with OpenAI’s separate openai-guardrails-python package (in preview), which covers PII redaction and jailbreak detection.

The OpenAI platform covers infrastructure-level compliance, but app-level security (credentials, sandboxing, and tool approval) stays with you, and OpenAI advises designing agent systems assuming prompt-injection and exfiltration attempts. The platform holds SOC 2 Type II and ISO 27001 certifications (per the OpenAI Trust Portal), signs BAAs for HIPAA-eligible API services, and offers API data residency in 10 regions for eligible customers.

Mastra

Mastra is a TypeScript-native agent framework built by the team behind Gatsby, with Tony Kovanen (a Next.js cocreator) as founding engineer. Mastra (YC W25) has raised about $35 million, including a $22 million Series A led by Spark Capital in April 2026. It has about 29,400 GitHub stars, about 10 million monthly npm downloads of @mastra/core, and production adoption at Replit, PayPal, Sanity, and Brex.

Developer experience

If you know TypeScript, most of Mastra will feel familiar. Agents, tools, and workflows are plain TypeScript with Zod validation. Models are reached through Mastra’s own model router, which covers over 200 providers, and Vercel AI SDK providers remain supported as an option. Running mastra dev opens Mastra Studio at localhost:4111, along with Swagger UI and autogenerated OpenAPI docs out of the box.

The trade-offs are:

  • Workflow branching on deterministic (non-LLM) logic can feel clunkier than plain TypeScript control flow
  • Fast-moving APIs: Agent Networks, for example, are now deprecated in favor of supervisor agents

Agent capabilities

Mastra combines ReAct-style autonomous agents with a graph-based workflow engine and LLM-routed supervisor agents, purpose-built for TypeScript teams.

The framework can help you:

  • Build graph-based TypeScript workflows: Use the .then(), .branch(), and .parallel() operators, which are the TypeScript equivalent of LangGraph’s stateful orchestration.
  • Coordinate agents via supervisor agents: Give an agent a set of subagents, and the supervisor LLM decides which subagent handles each input. No manual routing logic is required.
  • Deploy to serverless environments natively: Mastra officially supports Vercel, Cloudflare Workers, and Netlify through built-in deployers.
  • Get automatic context compression: Mastra’s Observational Memory compresses tool-call-heavy conversations 5–40 times and scores about 95% on the LongMemEval benchmark with gpt-5-mini.
  • Debug with time travel: Workflow runs support run.timeTravel(), which restarts from an earlier step with its original context, much like LangGraph’s checkpoint replay.

However, the framework can’t help you:

  • Get role-based abstractions out of the box: CrewAI ships roles, goals, and delegation as first-class primitives. Mastra’s supervisor agents delegate to subagents, but Mastra has no role, goal, or backstory primitives.

Context and memory

Mastra’s memory system is one of the most sophisticated in this comparison, with the following four types:

  • Message history: In a configurable window
  • Working memory: Uses Zod-validated JSON or markdown
  • Semantic recall: RAG via vector similarity
  • Observational Memory: Opt-in, then compresses history automatically (by default, once messages reach 30,000 tokens)

Mastra’s default storage is LibSQL, with PostgreSQL, MongoDB, and Upstash for production. However, LibSQL doesn’t work with file URLs in serverless environments, so teams on Vercel or Cloudflare Workers must configure an external storage backend.

Deployment and hosting

Mastra supports serverless deployment to Vercel, Cloudflare Workers, and Netlify, but it isn’t limited to serverless. Its self-hosted options include Express, Hono, Fastify, and Koa server adapters, plus an official Helm chart for Kubernetes. Mastra’s hosted offering, Mastra Platform, has self-serve sign-up and public pricing: a free Starter tier, a Teams tier at $250 per month, and custom Enterprise pricing.

Mastra’s core is Apache 2.0 licensed and free, but the project is now dual-licensed: code in ee/ directories (RBAC, SSO, FGA, and the agent builder) falls under the source-available Mastra Enterprise License and requires a license key. Another hidden cost is Observational Memory, whose background compression calls add to your LLM bill.

Security and compliance

Since Mastra 1.0 (January 2026), auth is configured with a stable auth key, with provider packages for JWT, Clerk, Better Auth, Supabase, Firebase, Auth0, and WorkOS. Built-in guardrails cover prompt injection detection and PII redaction.

Mastra runs a Vanta-powered trust center, and its Teams plan advertises SOC 2 docs, but Mastra doesn’t publicly state which SOC 2 report it holds. Enterprise buyers with strict SOC 2 requirements should request the report before committing.

Enterprise buyers should also know about a June 2026 supply-chain incident, in which an attacker used a compromised maintainer token to publish more than 100 malicious @mastra/* npm packages with a credential-stealing postinstall script. Mastra’s incident report lists what to check if you installed Mastra packages around June 16, 2026.

Vercel AI SDK

The Vercel AI SDK is the most widely adopted AI SDK in the JavaScript ecosystem, with about 140 million monthly npm downloads. It’s a TypeScript toolkit for web engineers shipping AI-powered features and agents in Next.js, React, Svelte, Vue, or plain Node.js. AI SDK 6 (December 2025) added a proper Agent interface, full MCP support, and a DevTools panel. AI SDK 7 (June 2026) added WorkflowAgent for durable, resumable execution, agent-level tool approvals, first-class timeouts, and telemetry.

Developer experience

The developer experience is excellent for its target audience: useChat and useCompletion handle streaming UI state automatically for any AI SDK provider, and Thomson Reuters built CoCounsel with only three developers in two months. Function timeouts are the main constraint outside the happy path (see Deployment and hosting below), so longer agents need WorkflowAgent.

Agent capabilities

The Vercel AI SDK runs a tool loop, in which stopWhen, isStepCount, and prepareStep control multi-step execution, and ToolLoopAgent provides the production-ready agent abstraction.

The framework can help you:

  • Build streaming AI UIs in React and Next.js with minimal code: The useChat and useCompletion hooks automatically stream state for any supported provider, including models available through AI Gateway.
  • Run multi-step agents: Use ToolLoopAgent with the prepareStep parameter for dynamic per-step control of the model, system prompt, and active toolset.
  • Integrate MCP servers for tool discovery: The SDK supports native MCP server integration.
  • Run durable, long-horizon agents: WorkflowAgent persists state at every step and resumes after process restarts and deploys. It runs on the open-source Workflow SDK, either on Vercel Workflows or self-hosted.
  • Deploy and monitor agents: Deploy Next.js apps to Vercel with zero configuration, use AI SDK telemetry or AI Gateway observability in production, and debug locally with the DevTools panel.

However, the framework can’t help you:

  • Build graph-based orchestration or complex multi-agent coordination: The SDK has no graph primitive. You can compose subagents as tools or hand-roll routing, but LangGraph’s graphs and Mastra’s workflows and supervisor agents are purpose-built for this, and the tool loop model doesn’t scale well to complex routing.

Context and memory

The Vercel AI SDK has no automatic token counting, summarization, or memory persistence layer, so context management is largely up to you, with helpers like prepareStep and pruneMessages for compacting context:

  • You can access the history in the useChat React state.
  • To configure server-side persistence, pass the original messages array and save it in the onEnd callback (called onFinish before AI SDK 7).

The AI SDK is well suited to projects that have simple memory requirements or already have session management. If you need automatic compression at scale, Mastra’s Observational Memory is a stronger choice.

Deployment and hosting

The AI SDK supports Vercel-first, zero-config, Next.js deployment, but the SDK itself runs on Express, Hono, Fastify, Deno, Bun, and Cloudflare Workers. AI SDK 7 requires Node.js 22 or later and is ESM-only.

Function timeouts matter for agents that run in a single request (per Vercel’s Fluid compute docs):

  • The Hobby plan has a 300-second default and maximum timeout.
  • The Pro and Enterprise plans have a 300-second default, configurable up to 800 seconds, or up to 30 minutes in beta.
  • Vercel Workflows, which WorkflowAgent runs on, have no duration limit.

The SDK is Apache 2.0 licensed and free. Vercel Pro costs $20 per month per developer seat and includes $20 of usage credit, with usage-based charges beyond that. Time spent waiting on LLM streams isn’t billed as CPU. It has a low lock-in risk at the SDK level, but it increases to medium-high for teams using Vercel’s full AI stack.

Security and compliance

The SDK has no built-in auth, input sanitization, or prompt-injection defenses: security is a platform concern, not an SDK concern. Setting needsApproval: true on tools provides human-in-the-loop gates, and AI Gateway Zero Data Retention mode handles sensitive workloads. Vercel’s platform carries SOC 2 Type II, ISO 27001, HIPAA (BAA available), PCI DSS, and GDPR compliance.

In April 2026, Vercel disclosed a security incident traced to a compromised third-party AI tool and an OAuth grant, a reminder to audit the integrations connected to your Vercel account.

n8n

n8n is a visual workflow automation platform with built-in AI agent capabilities, not a code-first agent framework. It has about 210,000 GitHub stars and was valued at $5.2 billion after SAP’s strategic investment in May 2026, up from $2.5 billion at its October 2025 Series C. It is the right tool for connecting APIs and exposing AI workflows to non-technical teams.

Developer experience

The visual drag-and-drop editor with over 400 prebuilt nodes is excellent for its target: connecting APIs, building business automations, and exposing AI workflows to non-technical teams without code. The ceiling appears when workflows require dynamic branching on unpredictable runtime data: LangGraph’s conditional edges handle this natively, while n8n’s IF/Switch nodes are more static and the canvas becomes a liability.

Agent capabilities

n8n runs AI agents as nodes in a visual workflow canvas. The AI Agent node is built on LangChain.js and works as a Tools Agent (the older agent types, including ReAct, are deprecated). An AI Agent Tool sub-node lets one agent call another, and built-in integrations, plus the HTTP Request, Code, workflow, and MCP tools, can serve as agent tools.

The framework can help you:

  • Connect AI reasoning to real-world APIs without writing integration code: The over 400 prebuilt nodes make n8n quick to build with for hybrid automations that combine deterministic logic with AI reasoning.
  • Build simple multi-agent delegation: Use the AI Agent Tool sub-node to have one agent hand work to another.
  • Expose AI workflows to non-technical teams: The visual canvas builder and form triggers are ideal for teams without developer experience.
  • Integrate MCP servers for tool discovery: n8n has dedicated nodes for integrating MCP servers.

However, the framework can’t help you:

  • Build complex agent collaboration: LangGraph and CrewAI are architecturally designed for complex collaboration, and n8n’s canvas becomes unwieldy for dynamic branching on unpredictable runtime data.
  • Track token-level costs per agent run: n8n shows LLM token usage in execution logs but has no built-in per-run cost tracking, whereas LangSmith and Langfuse offer it natively. Self-hosted instances can send traces to LangSmith.

Context and memory

The Simple Memory tool (formerly Window Buffer Memory) works in development, but the conversation history it stores is lost on workflow restart, and it doesn’t work in queue mode because calls may go to different workers, making it unreliable for production. Persistent memory requires an external backend, such as Postgres, Redis, or MongoDB Chat Memory, or vector stores, like Qdrant or Pinecone. When setting up an external backend, take care not to hardcode session IDs. Hardcoded session IDs cause all users to share memory, which is an easy configuration mistake to make but hard to debug.

Deployment and hosting

You can deploy to n8n Cloud, which is hosted on Azure Frankfurt, or you can self-host a Docker deployment. n8n Cloud offers a Starter plan (2,500 executions per month, €20 per month billed annually), a Pro plan (10,000 executions per month, €50 per month billed annually), and a custom Enterprise plan, according to the n8n pricing page. The self-hosted Community Edition is free with no execution limits, and the self-hosted Business plan costs €667 per month. Self-hosted deployments default to SQLite, but PostgreSQL is recommended for production, and Redis is only needed if you scale out with queue mode. Billing is per workflow execution rather than per step, so complex multi-step workflows don’t cost more than simple ones.

n8n uses a fair-code license (the Sustainable Use License, not OSI approved), which permits internal use and self-hosting but doesn’t allow you to resell n8n or build a product for which n8n provides the core value.

Security and compliance

n8n Cloud is SOC 2 Type II certified and GDPR compliant (with data in Frankfurt). All n8n Cloud instances are encrypted at rest with AES-256, and credentials are encrypted in every edition. RBAC is available on all paid plans (custom roles are Enterprise-only), and the Business and Enterprise tiers add SAML SSO and LDAP authentication. However, n8n isn’t HIPAA certified and doesn’t offer a BAA, so teams with healthcare compliance requirements should use LangSmith instead.

Self-hosters should also patch promptly. In early 2026, n8n disclosed several critical vulnerabilities, including CVE-2026-21877, a critical (CVSS 9.9–10) authenticated remote code execution flaw fixed in version 1.121.3, and CVE-2026-21858 (“Ni8mare”), an unauthenticated remote code execution flaw in webhook parsing.

Other frameworks worth a look

The following three frameworks matured quickly in 2026, but we haven’t evaluated them against all five criteria yet.

Google Agent Development Kit

Google’s Agent Development Kit (ADK) reached 2.0 in May 2026, and the latest Python release is 2.14.0. It’s optimized for Gemini but model-agnostic, with a graph-based Workflow Runtime (routing, fan-out and fan-in, loops, retries, and human-in-the-loop), a Task API for agent-to-agent delegation, and MCP and OpenAPI tools. ADK is also available for TypeScript, Java, and Go (on 2.x since June 2026), and it deploys to Cloud Run or Vertex AI Agent Engine.

Microsoft Agent Framework

Microsoft Agent Framework 1.0 went GA in April 2026 as an open-source framework for agents and multi-agent workflows in .NET and Python. It combines AutoGen’s agent abstractions with Semantic Kernel’s enterprise features, and AutoGen itself is now in maintenance mode.

Claude Agent SDK

Anthropic’s Claude Agent SDK is available for Python and TypeScript. It offers two interfaces: query() starts a new session per call, while ClaudeSDKClient reuses one session across multiple exchanges. Its options cover MCP servers (including in-process MCP tools), hooks, tool permissions, and subagents.

What happened to Vellum

Earlier versions of this guide included Vellum, a hybrid platform that paired a visual workflow builder with a Python SDK. In May 2026, Vellum relaunched as a personal AI assistant, and it is now shutting that platform down, with logins ending on December 13, 2026. The workflow builder is no longer marketed, and the Python SDK has had only one release since March 2026, so we don’t recommend starting new projects on it.

If you picked Vellum for its visual builder, n8n is the closest alternative in this comparison. If you mainly worked in the SDK, LangGraph gives you graph-based workflows with built-in checkpointing.

Wrapping up

No framework perfectly meets all five criteria. Use the following three questions to determine the best choice for your use case:

  • What is your primary language and runtime?

    • Python teams building stateful production agents should start with LangGraph.
    • Teams that prioritize type safety and developer experience should consider PydanticAI.
    • TypeScript teams get the most built-in features from Mastra (or the Vercel AI SDK if their primary use case is streaming web UI).
  • How complex is your orchestration?

    • Simple tool loops on OpenAI belong in the OpenAI Agents SDK.
    • Teams standardized on Google Cloud, Microsoft, or Anthropic’s Claude can also look at Google ADK, Microsoft Agent Framework, or the Claude Agent SDK.
    • Role-based multi-agent collaboration is usually fastest to prototype in CrewAI.
    • Multi-step stateful workflows in Python belong in LangGraph, and in TypeScript, Mastra.
    • Visual workflows for non-technical teams belong in n8n.
  • Who builds and maintains the agents?

    • Mixed technical and non-technical teams should use n8n for the non-technical layer and a code-first framework for complex orchestration.
    • Teams building MCP servers to expose internal tools and APIs to their agents should evaluate the Speakeasy AI Control Plane alongside their framework of choice.

The following table recaps the frameworks we discussed. Rows for Google ADK, Microsoft Agent Framework, and Claude Agent SDK include only what we’ve verified so far:

FrameworkParadigmOrchestrationMulti-agent nativeBuilt-in memoryManaged hostingLicense
LangChainPython and JS/TS agent frameworkReAct loop (create_agent)Via subagents & handoffsCheckpointer state & storeLangSmith DeploymentMIT
LangGraphGraph-based runtimeGraph/cyclicYesState & checkpointingLangSmith Deployment (Plus $39/seat/mo + usage)MIT
CrewAIMulti-agent frameworkRole-based crews & flowsYes (core feature)Unified MemoryAMP Cloud/FactoryMIT
PydanticAIType-safe Python AI framework (v2)Single-agent & pydantic-graphVia tools, delegation & graphsConversation store (bring your own DB)None (library only)MIT
OpenAI Agents SDKPython & TypeScript agent SDKImperative Runner loopHandoffsSessions (opt-in)None (library only)MIT
MastraTypeScript agent frameworkReAct & graph workflowsYes (supervisor agents)Working memory, semantic recall & Observational MemoryMastra Platform (free Starter, $250/mo Teams)Apache 2.0 core, Enterprise License for ee/
Vercel AI SDKTypeScript AI & agent SDKTool loop & WorkflowAgentSubagents as toolsNo (manual)Any Node.js host (Vercel optional)Apache 2.0
n8nVisual workflow automationEvent-driven & AI nodesVia AI Agent Tool sub-agentsSimple Memory (dev) & external storesn8n Cloud (€20–50/mo billed annually; Enterprise custom)Sustainable Use
Google ADKPython, TypeScript, Java & Go agent frameworkGraph-based Workflow RuntimeYes (Task API delegation)Not evaluatedCloud Run or Vertex AI Agent EngineNot evaluated
Microsoft Agent Framework.NET & Python agent frameworkAgents & multi-agent workflowsYesNot evaluatedNot evaluatedOpen source
Claude Agent SDKPython & TypeScript agent SDKquery() or ClaudeSDKClient sessionsSubagentsNot evaluatedNot evaluatedNot evaluated

AI everywhere.

Control here.