Agent Frameworks Compared: LangGraph, CrewAI, OpenAI Agents SDK, or Plain Code
By Waseem Ahmad — Full Stack Developer & AI Engineer ·
TL;DR
- A surprising share of "agent" requirements are satisfied by a single structured-output LLM call. Reach for a framework only after you have confirmed you need durable state, multi-agent handoffs, or audit-trail checkpoints.
- LangGraph is the strongest general-purpose choice for production workflows that must survive restarts, branch conditionally, and support human-in-the-loop approval gates.
- CrewAI gets a role-based prototype running fast, but its control-flow ceiling shows up once you need conditional branching or state rollback in regulated workflows.
- The OpenAI Agents SDK is the lowest-friction path if you are already committed to OpenAI models and want handoff patterns in under 100 lines of Python. The April 2026 update added sandboxing, MCP support, and configurable memory.
- Framework migration is painful. Picking the wrong abstraction early can cost a full engineer-quarter to undo.
Why framework choice is an architecture decision now
A year ago, "pick a framework" felt like picking a testing library. Today it is closer to picking a database. By 2026, the choice of framework is an architecture decision with the same weight as choosing a database or a message bus. Get it wrong, and the cost shows up later, in the form of workflows that cannot be resumed after a crash, decisions that cannot be audited, and tool calls that cannot be paused for human review.
Migrating tool definitions, memory schemas, and observability plumbing between frameworks routinely consumes an engineer for a quarter. That is the number that concentrates the mind. Before comparing frameworks, it is worth asking whether you need one at all.
Do you actually need a framework?
An AI agent is a program that loops between calling an LLM and executing tools the LLM picks, until a goal is reached. The whole pattern fits in roughly 60 lines of Python. Frameworks add convenience for some patterns and complexity for others.
A single LLM call with structured output handles classification, summarization, and extraction. Function calling handles single-tool single-turn agents. If your requirement fits either of those descriptions, adding a framework introduces dependency surface area, version-pinning overhead, and abstraction you will spend time fighting.
Many patterns are a few lines against a raw LLM API. Reach for a framework once you need durable state, multi-agent handoffs, streaming, and observability. Those are the real selection criteria. Everything else is secondary.
For a deeper look at where the agent pattern is genuinely necessary versus where a simpler workflow suffices, see What an AI Agent Actually Does in Production (and When You Don't Need One).
The three frameworks worth understanding
Three frameworks, three philosophies: the OpenAI Agents SDK treats agents as imperative handoff chains, LangGraph models them as explicit state machines over a graph, and CrewAI composes them as role-driven crews with declarative tasks. The mental model you adopt shapes how your codebase evolves, what your observability looks like, and which failure modes you will fight at 2 AM.
LangGraph
LangGraph is LangChain's graph-based framework for building stateful, multi-step AI agents. Unlike simple chains, LangGraph lets you define nodes (functions), edges (transitions), conditional branching, loops, and human-in-the-loop checkpoints.
The key production differentiator is checkpointing. LangGraph v0.4 ships a redesigned interrupt system: HITL checkpoints now surface automatically in .invoke() responses, state persists durably in Postgres or Redis, and multi-step approval flows can be resolved in a single call. LangGraph v0.4, released April 2026 per the LangGraph changelog, centres on making human-in-the-loop interrupts first-class citizens of the framework rather than an advanced pattern requiring significant custom plumbing.
Compliance audit trails in regulated industries need a complete record of every agent decision. LangGraph's checkpoint history provides this out of the box. That matters for fintech and healthcare workflows where you cannot reconstruct what happened from logs alone.
The cost is upfront complexity. You define state schemas explicitly, compile the graph before running it, and reason about edge conditions before you have seen them in the wild. For teams that want something running by end of day, this feels heavy. For teams that have been burned by a stateless agent loop losing context mid-run, it feels exactly right.
CrewAI
CrewAI's role-based abstraction produces working multi-agent systems in twenty to fifty lines of Python. That is a genuine virtue for prototyping and for workflows that map naturally to distinct specialist roles: a researcher, a writer, a reviewer.
The ceiling arrives when the workflow needs to be non-linear. CrewAI gets you to a working prototype in two days. Then you hit the wall: the role-based paradigm cannot cleanly express the conditional branching and state rollback that regulated workflows require. The pragmatic move is to rebuild in LangGraph, and that rebuild typically takes about a week.
The CrewAI to LangGraph migration is the most common framework migration in 2026. Teams prototype in CrewAI, validate the concept, then hit CrewAI's control flow ceiling. If your use case involves approval gates, rollback, or resumability after failure, skip the intermediate step and start in LangGraph.
OpenAI Agents SDK
Released in March 2025, the OpenAI Agents SDK replaced the experimental Swarm framework with a production-grade toolkit. The core abstraction is the handoff: agents transfer control to each other explicitly, carrying conversation context through the transition. Each agent is defined with instructions, a model reference, tools, and a list of agents it can hand off to.
The April 2026 update changed the calculus for enterprise adoption. It now has configurable memory, sandbox-aware orchestration, Codex-like filesystem tools, and standardized integrations with primitives that are becoming common in frontier agent systems. The release adds native sandbox execution, a subagent pattern, a planned code mode, Codex-style filesystem tools, and first-class MCP support.
The vendor concern is real but less absolute than it looks. The SDK is not locked to OpenAI's own models. While optimized for OpenAI models, the SDK works with more than 100 other LLMs through the Chat Completions API. That said, the observability, tracing, and first-party integration story is strongest when you stay on OpenAI's stack.
One migration pressure worth tracking: OpenAI plans to formally deprecate the Assistants API, with a target sunset date in mid-2026, and will provide a migration guide to help developers move their applications to the Responses API. If you have anything running on the Assistants API, that work is not optional.
When does a plain loop win?
Plain code wins when the requirements are genuinely simple. A loop that calls an LLM, parses structured output, and dispatches to one of three functions is faster to write, easier to test, and easier for the next engineer to read than the equivalent CrewAI crew. Every agent framework converges on the same underlying architecture. The framework is just scaffolding around a loop you could write yourself.
Plain code also wins when your team owns the failure modes better without an abstraction layer. Framework errors often surface as opaque exceptions from inside the framework's internals. When something goes wrong in a hand-rolled loop, the stack trace points directly at your code.
The signal to reach for a framework is when you are writing the same plumbing for the third time: retry logic, state serialization, tool-call dispatch, streaming. At that point, the framework is paying for itself.
How do the options compare?
| Option | State management | Human-in-the-loop | Multi-agent | Time to first working agent | Best fit |
|---|---|---|---|---|---|
| Plain Python loop | You own it | You build it | You build it | Minutes | Simple, linear, well-understood workflows |
| OpenAI Agents SDK | Implicit via handoff context | Guardrails and sandboxing (April 2026) | Native handoffs, subagents rolling out | Under an hour | OpenAI-native teams; rapid pilot; handoff-heavy routing |
| CrewAI | Shared crew context | Limited; no native interrupt-resume | Role-based, declarative | Hours | Prototyping role-based workflows; concept validation |
| LangGraph | Explicit, checkpointed (Postgres or Redis) | First-class since v0.4 | Node-per-agent, full graph control | Half a day to a day | Production workflows needing durability, audit trails, conditional branching |
What does the framework choice look like in a real project?
On the Biz365 AI engagement, the agentic layer needed to coordinate multiple specialist sub-tasks, pass structured results between steps, and be auditable. That kind of requirement pushes firmly toward LangGraph's explicit state model rather than a role-based abstraction. The graph structure makes it straightforward to add a checkpoint before any destructive operation and to replay or inspect individual runs when something goes wrong.
If your agent work involves connecting to existing systems through standardized tool interfaces, the MCP picture matters too. The Model Context Protocol is becoming the standard for tool integration, and all the major frameworks are adding MCP support in 2026. For how that wiring works in practice, see MCP Server Development: Wiring an AI Agent into Systems You Already Run.
For token efficiency when designing those MCP tool interfaces, see Designing MCP Tools That Don't Blow Up the Context Window.
If you are working through which approach fits your specific situation, the AI agents service page covers how that engagement works.
FAQ
Is LangGraph too complex for a small team?
It depends on the workflow, not the team size. If your agent needs to loop, branch, resume after failure, or wait for human approval mid-execution, you need LangGraph. Most production agents end up in the second category. If your workflow is genuinely linear and stateless, LangGraph adds overhead with no payoff. The deciding question is whether your agent needs to survive a process restart or wait for a human to come back three days later.
Can I start with CrewAI and migrate to LangGraph later?
The migration path maps each CrewAI agent to a LangGraph node, converts the sequential or hierarchical process to explicit graph edges, and moves shared context into LangGraph's state object. Expect one to two weeks for a moderately complex system. The agent logic, prompts and tools, transfers directly; it is the orchestration layer that changes. The migration is doable, but it is real work. If you already know you will need conditional branching and state persistence, starting in LangGraph is faster overall.
Does the OpenAI Agents SDK lock me into OpenAI models?
Less than it used to. The most underrated aspect of the 2026 update is its provider-agnostic design. The SDK now works with over 100 non-OpenAI LLMs via the Chat Completions API. The tradeoff is that first-party tracing, guardrails, and the tightest model alignment still favor OpenAI's own models. If model portability is a hard requirement, LangGraph's model-agnostic design gives you more flexibility without rewriting your orchestration layer.
When should I just write a plain Python loop?
When the task is a single LLM call with structured output, or a simple sequence of two or three tool calls with no branching. The whole agent loop pattern fits in roughly 60 lines of Python. A framework earns its complexity when you need retry logic, checkpointing, streaming, multi-agent handoffs, or observability. Before adding a framework, write the loop and see what plumbing you find yourself building. If you are reinventing state serialization and retry backoff, that is the signal to reach for something more structured.
Hire me for similar projects
Looking for a developer who can build what you just read about? Let's talk.
Get in Touch