Skip to main content

AI agent frameworks compared on what breaks in production

AI agent frameworks compared on what breaks in production

Picking between AI agent frameworks comes down to what your agent does when a step fails. LangGraph fits agents that are the product and need checkpoints and approval gates. CrewAI fits internal multi-step jobs where a wrong path costs a re-run. The OpenAI Agents SDK fits teams already on OpenAI who want a thin layer with tracing and approvals built in, and plain code fits a single bounded tool loop.

All four look identical on the happy path. You hand each one a task, it calls a few tools, it returns a result, and the demo ends. The differences show up when a tool call returns a 400, a step times out, or a run that cost cents in a demo costs dollars at volume. This comparison scores the four on the axes that decide whether an agent holds up in production. If you have already narrowed it to two, the CrewAI vs LangGraph head-to-head builds the same agent in both and walks through the third retry.

What do AI agent frameworks give you?

Strip away the marketing and an agent framework bundles four capabilities. The first is a state model, meaning how a run carries data between steps. The second is retry semantics: what happens when a tool call fails, and who decides. Tracing is the third, so you can see which branch a run took after it finished. Human-in-the-loop is the fourth, letting a run pause for approval before a consequential action. Three more properties decide production fit and appear in the table further down: streaming, cost visibility and deployment shape.

A framework is a bet on defaults. It hands you those four capabilities pre-built and charges you twice, once in constraints you work around and again in per-step context you did not write but still pay tokens for. Plain code gives you none of the four for free, and you pay for each one you build yourself.

LangGraph, explicit state machines

LangGraph models an agent as a graph. Nodes are steps, edges are transitions, and a typed state object carries everything between them. A conditional edge after a node routes to different nodes based on a field in that state. You write more code on the happy path than with the other options, because the nodes, edges and state schema all exist before anything runs.

That code pays off on failure. LangGraph lets you attach retry policies and timeouts per node, so a CRM call that returns a 400 on attempt three is a node you point at and fix in isolation. A checkpointer saves state at each step, which is what makes pause and resume work: the graph interrupts, a person approves, and the graph resumes from the same state. The LangGraph persistence docs cover the checkpointer and thread model. State streams node by node, so a failed run points at the node that raised, with inputs and outputs attached.

You pay in tokens and ceremony. Nothing stops you from putting the full message history in state and re-reading it at every node, and that compounds cost. LangGraph makes that choice visible in your code but leaves the choice to you. It is our default when the agent is the product and its failure modes reach customers.

CrewAI, role delegation plus Flows

CrewAI models the same job as roles and tasks. You define a researcher agent with a goal, a writer agent with a goal, the tasks, and the crew that runs them, either sequentially or under a manager agent in a hierarchical process. You never write a graph, so the happy path lands faster than in LangGraph.

Inside a crew, the flow stays implicit. When a tool call inside a task fails, the framework decides what gets retried and what state carries forward. Task-level guardrails with a guardrail_max_retries setting and a human_input flag cover the simple cases. Debugging "why did it loop three times before failing" still means reading crew logs instead of inspecting a typed state object. Token cost is structural too: CrewAI injects each agent's role, goal and backstory into its prompt, plus prior task outputs, so spend grows with the depth of the crew and stays out of sight until you read the assembled prompts.

CrewAI has closed part of that gap with Flows, an event-driven layer with structured state, a @router decorator for branching, @persist for state that survives restarts, and a @human_feedback decorator (CrewAI 1.8.0 and later) that pauses for approval. If you pick CrewAI for anything customer-facing, put the control flow in a Flow and keep crews for the steps inside it. For research pipelines, content generation and bounded internal jobs, a plain crew is often enough.

OpenAI Agents SDK, the thinnest useful layer

The OpenAI Agents SDK is the newest and smallest of the three frameworks. An agent is a model with instructions and tools, run in a loop. On top of that you get handoffs between agents, guardrails that validate input and output, sessions for conversation memory (SQLite and SQLAlchemy backends ship with it), and tracing that is on by default. It defaults to the Responses API but also supports Chat Completions and other model providers. There is no graph to define and no roles to assemble.

Its strength is staying out of your way. Most of the code you write is your own prompts and tool functions. Human-in-the-loop is a first-class feature now: you mark a tool with needs_approval, the run returns the pending call as an interruption, and you can serialize the paused RunState and resume it after a person decides. The Agents SDK human-in-the-loop guide walks through the pause, approve and resume cycle. The state model stays thinner than LangGraph's. You get sessions and paused-run state, but no graph of named steps with per-node retry policies, so branching and retry logic live in your code.

Pick the OpenAI Agents SDK when your stack already runs on OpenAI models, the job is a tool-calling loop with a few handoffs, and you want tracing and approvals without adopting a graph engine.

No framework, 200 lines and a while loop

Plain code is the baseline every framework gets measured against. A minimal agent is a while loop: call the model, read the tool calls, run the tools, append the results, and repeat until the model stops asking for tools or you hit a cap. Two hundred lines gets you a working single-agent loop with a retry, a tool registry and a hard stop.

You lose everything the frameworks pre-build. There is no checkpointing, no interrupt and resume, no built-in tracing and no structured branch history. Each of those becomes your code, and they are the parts that fail in production. In return you get zero dependency churn, zero per-step scaffolding tokens, and every line in view because you wrote it. Plain code fits a single tool-calling agent with a bounded job and no approval step. Once you need retries that mean something, resumable runs or a branch you can inspect afterwards, you are rebuilding a framework one feature at a time.

AI agent frameworks comparison table

DimensionLangGraphCrewAIOpenAI Agents SDKPlain code
State modelTyped graph state, checkpointed per stepImplicit in crews; structured state in FlowsSessions plus serializable paused-run stateWhatever you keep in variables
Retry semanticsPer-node retry policies, timeouts, fallback edgesFramework-managed in crews; task guardrail retriesClient-level HTTP retries, the rest is your codeYou write every retry
TracingNode-level state streaming, LangSmithCrew logs plus third-party tracing integrationsBuilt-in traces, on by defaultNone unless you add it
Human-in-the-loopFirst-class interrupt and resumehuman_input on tasks, @human_feedback in Flowsneeds_approval on tools, resume from RunStateYou build the queue
StreamingNode-by-node state eventsPartial, log-orientedRun-level event streamingYour loop, your choice
Cost visibilityYou pass state, so visibleRole scaffolding injected, less visibleModel usage per run, visible in tracesFull, it is your code
Deployment shapeLong-running graph serviceBatch crew runs or Flow servicesThin service around the model APIYour own process

These entries are qualitative defaults, drawn from each project's documentation as of September 2026. They are not benchmarks. Defaults decide your week-three incident more than any vendor demo does, and all four projects ship changes monthly, so check the docs for the version you pin.

Which is the best AI agent framework for your product?

Let the product decide. We use four rules, and the first one that matches wins.

  1. If the agent is the product and its wrong answers reach customers, start with LangGraph. The graph is what you debug, and each failure is a node you can name.
  2. If the agent is an internal shortcut and a wrong path costs a re-run, CrewAI gets a prototype working fastest. Move the control flow into a Flow once it needs approvals or restarts.
  3. If your stack already runs on OpenAI and the job is a bounded tool-calling loop, the OpenAI Agents SDK is the thinnest option that still gives you tracing and approval gates.
  4. If the job is one model-call loop with no approval step, plain code wins, because a framework would add tokens and nothing else.

Real agents sit between the buckets. An agent that reads supplier emails and drafts purchase orders, like the AI procurement agent we built, starts as an internal shortcut and becomes production the moment it touches money. That shift pulls it out of plain code and toward explicit state with an approval gate. Our working test: if you cannot say what the agent should do when step three fails, you have a design problem, and no framework choice will fix it. The framework only sets how expensive the answer is to find. Start with the failure mode, then pick the tool that makes that failure cheap to see and cheap to fix.

Once more than one agent is involved, the pattern matters as much as the framework. The AI agent orchestration patterns guide covers router, pipeline, supervisor and swarm, and which of them each framework models natively.

Do I need a framework, can I migrate later, and what breaks first?

Do I need a framework?

Not for one bounded loop. You need one when you want retries, tracing, checkpointing or human approval without writing each yourself. Let the failure you fear decide. If you need to resume a half-finished run after a crash, or prove which branch a run took, a framework does that job better than your first attempt will.

Can I migrate later?

Mostly yes, and cheaply on the happy path. Model calls, prompts and tool functions are strings and functions that port in a weekend. Control flow is the expensive part. Moving from CrewAI to LangGraph means pulling the implicit flow out into explicit nodes and state. Moving from LangGraph down to plain code means reimplementing checkpoints and interrupts. You can wrap explicit state in a higher-level API later, but you cannot recover state you never modeled, so starting with more explicit state is the cheaper mistake to undo.

What breaks first?

Retries and resumability. In a demo every step succeeds, so neither gets exercised. In production the third tool call fails with the run half done, and a framework that cannot pause or resume turns a retry into a loop or a dropped run. Test that path before you commit. Whichever framework you choose, instrument it from day one, because AI agent observability is how you learn which step fails and how often.

Next step

Pick one real task, write down what should happen when each step fails, and prototype it in the framework that makes those failure paths explicit. Agentic systems that take real actions treat orchestration, state and tool-execution safety as first-class concerns, which is the thread running through our Agentic AI work. If you already have an agent that will not stabilize, our AI development team can start with a diagnosis, or you can pick your stack in under a minute.

Written by

Tayyab Hanif

Leading client builds since 2019

Founder & CEO

Founder & CEO of Robust Devs. Leads delivery and works directly with every client, across AI marketing, healthtech, and fintech builds, and has done since 2019.

Connect on LinkedIn

More notes from production

Tactical writing for founders building AI products. Browse the archive for more field notes like this one.

Browse all articles
Notebook and laptop on a writing desk

Put these notes to work.

If you are building in this space, schedule your call or get in touch.