Agent Frameworks
LangGraph, CrewAI, AutoGen, Pydantic AI, Mastra — and when to skip them entirely
Once you've built a few agentic features by hand, you start wanting structure: state machines for the loop, retries, checkpoints, multi-agent coordination, durable execution. Agent frameworks aim at exactly this layer. They differ less in capability than in their opinion about what an agent should look like.
What an Agent Framework Provides
- Loop structure — a stable shape for "model decides, tool runs, model continues."
- State management — what carries forward between turns, what gets reset.
- Tool plumbing — declaring tools, dispatching calls, handling errors.
- Retries and checkpoints — survive transient failures and resume long runs.
- Multi-agent orchestration — when one agent isn't enough.
- Tracing hooks — visibility into what the agent did and why.
- Durable execution (some frameworks) — survive process restarts mid-task.
The Major Players
LangGraph — graph-based agent orchestration from the LangChain team. You define nodes and edges; the framework runs the state machine. Strong on structured workflows, branching logic, and long-running stateful agents. Ecosystem advantage if you're already in LangChain land.
CrewAI — opinionated about role-based multi-agent setups. You declare agents with personas and tasks; the framework coordinates them. Easy to get started; can feel constraining when your design doesn't fit the role-and-task mental model.
AutoGen (Microsoft) — flexible multi-agent framework, conversation-based coordination. More general than CrewAI, less structured than LangGraph. Strong research presence, used as the basis for several more focused tools.
Pydantic AI — Pydantic-style typed agents. Tools are typed Python functions; outputs are validated Pydantic models. Pleasant for teams already using Pydantic; deliberately small surface area.
Mastra — TypeScript-first agent framework. Workflows, tools, memory, evals in one package. Good fit if your stack is Node and you want one cohesive thing rather than five libraries.
Vercel AI SDK — focused on the streaming and UI side of agent applications, with growing tool-use and workflow support. The pragmatic choice for Next.js apps.
Inngest, Temporal, Restate — durable workflow engines, not AI-specific, but increasingly used for long-running agentic work where you need persistence across crashes.
Provider-native — Anthropic's Agent SDK, OpenAI's Agents SDK, Google's ADK. Tight integration with the corresponding provider, often the cleanest path if you're not multi-provider.
When You Need One
- Multi-step, branching workflows — explicit graphs are better than nested if-statements.
- Multi-agent coordination — managing several agents talking to each other manually gets ugly fast.
- Long-running tasks — runs that span hours need checkpoints and persistence.
- Production agentic systems — observability, retries, and recovery aren't optional once users depend on it.
When You Don't
- Single-turn or single-step features — you don't have an agent, you have a function call. Skip the framework.
- Short loops with predictable structure — a 50-line
whileloop is more debuggable than a graph definition. - Heavy customization — when your needs deviate from the framework's mental model, you'll spend more time fighting it than building.
The "Just Write the Loop" Option
The simplest agent is:
state = initial
while not done(state):
decision = model.respond(state, tools)
if decision.is_tool_call:
result = run_tool(decision)
state = update(state, decision, result)
else:
return decision.outputA few dozen lines, fully under your control, fully observable. For many production agents, this with good logging is plenty. Reach for a framework when you start feeling pain — not because the README sounded compelling.
Choosing
A rough mapping:
- Stateful, branching, durable, Python — LangGraph or Temporal+SDK.
- Multi-agent, role-based — CrewAI for opinionated, AutoGen for flexible.
- Typed, minimal, Python — Pydantic AI.
- TypeScript / Node — Mastra or Vercel AI SDK.
- Single-provider, simple — provider's own agents SDK.
- You're not sure you need one — write the loop, decide later.
A Word on Hype Cycles
The agent framework space turns over fast. Most projects that look essential today won't be the answer in eighteen months. Bet on small, focused libraries you can swap out, and keep the agent's actual logic — the prompts, the tools, the policies — separate from whatever orchestration library is in fashion.