AI agent frameworks: LangGraph vs OpenAI Agents SDK

These frameworks help build applications where a model chooses and uses tools. The useful difference is what each framework manages around that loop: state, retrieval, handoffs, tracing, or deployment. Use one when your application needs those features. If the steps are already known, start with ordinary workflow code.

Start with LangChain agents for a model-and-tools loop built on LangGraph. Use LangGraph directly when you need to decide how each step saves state, waits for approval, and resumes after a stop.

Choose by saved state, recovery, retrieval support, and the work required to deploy and maintain the application.

Recommendation table

NeedStarting pointWhy
High-level agent APILangChain agentsThe LangGraph docs recommend this layer when low-level orchestration is unnecessary.
Stateful production agentLangGraphIts runtime exposes graph state, persistence, interrupts, and low-level orchestration.
Compact model-and-tools loopOpenAI Agents SDKTools, guardrails, sessions, tracing, and handoffs share one API. Other model providers are supported.
RAG-heavy document agentLlamaIndexData loading, indexes, retrieval, query engines, tools, and agent workflows live in the same ecosystem.
Role-based multi-agent workflowCrewAIAgents, crews, flows, knowledge, memory, and observability match role-based automation.
Microsoft enterprise agentMicrosoft Agent FrameworkIt is Microsoft’s current unified agent SDK direction, combining ideas from Semantic Kernel and AutoGen.
Small code-first agentSmolAgentsMinimal surface area, code agents, tool-calling agents, and easy inspection.

How to choose

Start with control flow: how the agent moves between steps and handles failure.

If the agent has clear states, retries, approvals, checkpoints, and resumable runs, use LangGraph. For example, a run waiting for approval needs saved state so it can continue after the user responds. For a conventional model-and-tools loop, LangChain’s higher-level agents may be enough. Use the graph directly when you need to control how a stopped run resumes.

The OpenAI Agents SDK fits a compact Python loop with tools and handoffs. It also supports other providers, so using an OpenAI model is not a requirement. Check the selected model’s tool and structured-output support, plus where tracing sends data.

If your agent mostly works over documents, indexes, retrieval, and query engines, start with LlamaIndex. Its existing retrieval components can save you from writing those parts yourself. Before replacing the agent loop, check whether retrieval finds the right evidence and whether your tests expose missing or unsupported answers.

CrewAI is useful when the real process has roles: researcher, analyst, reviewer, writer, operator. It is less compelling when you invent roles just to use a multi-agent abstraction. A role name does not specify what happens when that agent fails.

Recovery needs its own test. Stop a run after a tool changes a file or sends a request, then check what happens on resume. Saved chat history alone does not show whether the application will repeat that side effect. Verify checkpoints, replay behavior, and duplicate-action handling in the configuration you plan to deploy.

For any framework, inspect what remains your responsibility: storage, credentials, retries, deployment, and evaluation. LlamaIndex’s retrieval features do not by themselves justify choosing it for unrelated workflow orchestration. CrewAI roles still need explicit state and error handling. Check Microsoft integration requirements against the rest of your stack, and expect to supply more of the runtime around a small SmolAgents experiment.

When not to use an agent framework

Do not start with an agent framework when a typed workflow, search endpoint, or rules engine solves the problem. Agents help when the system needs to choose the next step after seeing intermediate results. They are a poor fit for fixed ETL, deterministic approvals, billing flows, or anything where all branches are known ahead of time.

Do not build a multi-agent system before one agent works well. Splitting an unstable workflow across several agents adds coordination failures and latency.

Traces show which steps ran. Evaluation checks whether those steps completed the task correctly, within its permissions and budget.

Implementation sequence

  1. Use an ordinary workflow for known steps. Use one agent with narrow tools when a model must choose the next step.
  2. Add traces and a small regression dataset before adding memory.
  3. Use LangGraph directly when you need explicit control over saved state, approvals, and resuming runs.
  4. Test OpenAI Agents SDK when the loop should stay compact; check the chosen provider’s feature support.
  5. Add role-based agents only when responsibilities are truly separable.

Deeper reading

References