Engineering

Agentic AI frameworks: how to choose one for production work

Every agentic AI framework demos beautifully. The differences only show up three months in, when a run dies halfway through, a client asks why an agent did something, and the token bill arrives. Here is what actually separates them.

The short answer

An agentic AI framework supplies the loop, tool protocol, state and recovery around a language model. Choose LangGraph when runs are long and need durable checkpoints and approval gates; CrewAI when you want role-based collaboration running today; the OpenAI Agents SDK when you want minimal abstraction over one vendor; and your own loop when you have fewer than a handful of agents and value debuggability over features.

What an agentic framework actually does

Strip away the marketing and every agentic AI framework solves the same five problems. A language model can produce a tool call, but it cannot execute it, remember it, retry it, or know when to stop. The framework does that:

  • The loop. Call the model, read the response, execute any tool calls, append the results to the conversation, call again. Repeat until a terminal condition: a final answer, a step limit, or a budget ceiling.
  • The tool protocol. Turning Python or TypeScript functions into JSON schemas the model can call, then validating and coercing what comes back. Models routinely return a string where you declared an integer.
  • State. What survives between steps: the message history, intermediate artefacts, a scratchpad, retrieved documents. How much of it goes back into the next prompt is the single biggest driver of both cost and quality.
  • Control flow. Sequential steps, parallel fan-out with a join, conditional branches, loops with exit criteria, and delegating a sub-task to another agent.
  • Failure handling. Rate limits, timeouts, malformed tool arguments, a model that loops forever calling the same tool. In production this is most of the code.

Frameworks differ far less in what they do than in which of these they make explicit. That is the real axis of comparison, and it is why a framework that feels elegant in a tutorial can feel obstructive at scale, or the reverse.

The six criteria that actually decide it

After running agents in production against live client data, crawling sites, calling search and ads APIs and writing into client accounts, these are the properties that determined whether a framework helped or got in the way.

1. Durable state and resumability

A run that takes eleven minutes and calls six external APIs will die partway through. The question is what happens next. If your framework checkpoints state after each step to a real datastore, you resume from step four. If state lives in process memory, you start again, and pay for the first three steps twice. This single property separates frameworks suitable for long-running work from those built for chat-latency tasks.

2. Human-in-the-loop as a first-class concept

Any agent that writes to a client-facing system needs an approval gate. The naive version (pause, wait for a callback, resume) is genuinely hard, because it means suspending execution across a process boundary and possibly across days. Frameworks that model interruption natively make this a few lines. Frameworks that do not force you to decompose the agent into separate invocations and hand-roll the state passing.

The pattern that actually works

Do not ask an agent to "be careful". Structure it so the destructive step is not available to it. In Opaeron every agent that mutates an account emits a proposal object, never a write. A person confirms the proposal in the UI, and a separate, non-AI code path performs the write and records the audit entry. The agent literally cannot act unilaterally, so trust does not depend on prompt discipline.

3. Observability you can hand to a non-engineer

When a client asks why an agent recommended something, "the model decided" is not an answer. You need the full trace: every prompt, every tool call and its arguments, every result, token counts and cost per step. Some frameworks ship this; others expect you to instrument it. Retrofitting tracing onto an agent framework that did not plan for it is painful, because the interesting boundaries are inside the library.

4. Cost control at the loop level

An agent that re-sends its entire message history on every iteration has quadratic token growth. Ten steps of a growing context is not ten times the cost of one: it is closer to fifty. Look for explicit context-window management: message trimming, summarisation of older turns, and the ability to pass only a compacted state forward. Also look for a hard step ceiling and a token budget that aborts the run, because without one a looping agent will happily spend your month's budget overnight.

5. Escape hatches

You will eventually need to do something the framework's authors did not anticipate: a custom retry policy, a non-standard streaming format, a provider quirk. Frameworks that expose the underlying request let you drop down a level. Frameworks that fully encapsulate the model call leave you forking or abandoning them.

6. The dependency's own stability

This space moves fast enough that a framework's public API can change substantially inside a year. Pin versions, read the changelog before upgrading, and weigh how much of your system would need rewriting if the abstraction shifted. A thinner framework is a smaller bet.

The frameworks, compared

Scored on the criteria above rather than on feature checklists. All of these are actively maintained and all of them work. The question is which failure mode you would rather own.

Comparison of agentic AI frameworks on production criteria
FrameworkModelDurable stateHuman-in-the-loopBest forMain cost
LangGraph Explicit graph of nodes and edges over a typed state object Native, pluggable checkpointer, resume from any step Native, interrupt and resume built in Long-running, resumable workflows with approval gates Steepest learning curve; you model the graph yourself
CrewAI Role-playing agents with goals, delegating to each other Limited, largely in-process Partial Fast prototypes of multi-role collaboration Emergent behaviour is hard to constrain or debug
AutoGen Conversational multi-agent, agents message each other Partial Native via a user-proxy agent Research, code execution, exploratory problems Conversation-shaped control flow gets costly
OpenAI Agents SDK Thin loop with handoffs and guardrails Partial, session-scoped Partial Staying close to one vendor with minimal abstraction Vendor coupling; less useful multi-provider
LlamaIndex Workflows Event-driven steps emitting and consuming events Yes, with context serialisation Partial Retrieval-heavy pipelines over your own corpus Strongest when the problem is mostly retrieval
Build your own A loop you wrote, over a message list Whatever you implement Trivial, it is your code A handful of well-understood agents You own retries, tracing and schema handling

The case for not using a framework

This is underrated. A working agent loop is genuinely small:

Call the model with the message list and tool schemas. If the response has tool calls, execute them, append the results, and call again. Otherwise return. Stop after N steps or when the token budget is exhausted.

That is roughly forty lines. Production-hardening it (typed tool schemas, validation and coercion, exponential backoff on rate limits, per-run cost accounting, structured tracing, a step ceiling) takes it to perhaps three or four hundred. In exchange you get a system where every behaviour is in your repository, stack traces point at your code, and no upgrade can silently change how your agents behave.

Most of Opaeron's twenty-plus agents work this way. Each one is a scoped pipeline: gather inputs from real APIs, do deterministic processing in ordinary code, call the model at the specific points where judgement is genuinely needed, then write a structured result. The model is a component inside a workflow, not the workflow itself.

A useful rule of thumb

If you can draw the steps on a whiteboard and they do not change between runs, write a workflow and call the model at the uncertain steps. Reach for agent orchestration only when the path genuinely cannot be known in advance. Teams routinely reach for agents where a workflow would be cheaper, faster and far easier to debug, and then blame the model for the unreliability.

Five patterns that show up in every real deployment

  1. Router. One cheap model classifies the request and dispatches to a specialised handler. Most of the reliability win, almost none of the cost.
  2. Deterministic sandwich. Code gathers the data, the model does one bounded judgement step, code validates and persists the result. The model never touches I/O directly.
  3. Fan-out and reduce. Run N independent analyses in parallel, then have a final step reconcile them. Effective for audits and reviews where coverage matters more than depth.
  4. Propose and confirm. The agent produces a structured proposal; a person approves; ordinary code executes. Non-negotiable for anything client-facing.
  5. Adversarial verification. A second pass whose only job is to refute the first pass's findings. Expensive, and the single most effective way to stop plausible-but-wrong output reaching a client.

So which one should you use?

Answer three questions honestly. How long does a run take? Under thirty seconds, durability barely matters and almost anything works. Over several minutes with external API calls, you need real checkpointing. Does it write anything a client sees? If yes, human-in-the-loop is a hard requirement, not a feature you will add later. How many distinct agents will you actually run? Below about five, a shared abstraction is overhead; above twenty, you will want one.

For most teams building serious AI agents for marketing and operations work, the honest answer is a hybrid: deterministic workflows for the ninety percent of steps whose shape you already know, a well-instrumented agent loop for the genuinely open-ended parts, and a framework only where its specific strength, usually durable resumption, pays for its abstraction.

Frequently asked questions

What is an agentic AI framework?
An agentic AI framework is a library that handles the machinery around a language model so it can complete multi-step work: the loop that calls the model repeatedly, the tool-calling protocol, the state carried between steps, error handling and retries, and the points where a human approves an action. The model supplies the reasoning; the framework supplies the control flow, durability and observability.
Which agentic AI framework is best for production?
There is no single best framework. For long-running, resumable workflows that need durable state and approval gates, LangGraph's checkpointing model is the strongest fit. For fast prototypes of role-based collaboration, CrewAI is quickest to a demo. For staying close to one vendor's tool-calling and tracing, the OpenAI Agents SDK is the least abstraction. For a small number of well-understood agents, writing the loop yourself is often the cheapest long-term choice.
Do I need a framework to build AI agents?
No. A production agent can be a while-loop that calls a model, dispatches tool calls, appends results to a message list and stops on a terminal condition, often 200 to 400 lines including retries and tracing. A framework earns its place when you need durable checkpointing, parallel fan-out with joins, streaming partial state to a UI, or one shared abstraction across many teams.
What is the difference between agent orchestration and a workflow?
In a workflow the control flow is written by you in code: the sequence of steps is fixed and the model fills in content at each step. In agent orchestration the model decides which tool to call next and when the task is done, so the path varies between runs. Workflows are more predictable and cheaper to debug; orchestration handles tasks whose shape is not known in advance. Most reliable production systems are workflows with a small agentic segment inside them.
How do you control the cost of an agentic system?
Four levers, in order of impact: cap the number of steps per run; manage the context window explicitly rather than re-sending the full history each iteration; route cheap classification work to a smaller model; and record cost per run so regressions are visible. A hard token budget that aborts the run is the backstop. Without it, a looping agent can spend a month's budget overnight.

See agentic AI doing real agency work

Opaeron runs twenty-plus production agents against live client data such as site crawls, search APIs and ad platforms, with every action proposed, confirmed by a person, and written to an audit log.

See the platform