Explainer
AI Agent Frameworks: Do You Actually Need One?
An AI agent is a ~100-line loop. A framework does four jobs on top. Learn when LangGraph earns its keep, and why the first upgrade most teams need lives underneath.
Watch the explainer
You decided to build your own agent loop. Just a hundred lines, no need for LangGraph. Six weeks later you are staring at two thousand lines of retry logic, state handling, and approval gates you never planned to write. Congrats. You have built a worse version of the exact framework you swore off, and you are the only person alive who understands it.
That trap is the whole debate in miniature. This article covers what an AI agent framework actually does, when it earns its place, and the one upgrade almost everyone reaches for in the wrong direction.
What is an AI agent framework?
An AI agent framework is a library like LangGraph, CrewAI, or PydanticAI that wraps the model-and-tools loop and does four jobs for you. Strip the marketing and that is all it is: it writes your boilerplate (defining and parsing tools), manages your state (history, memory, checkpoints), handles orchestration (the routing between steps), and runs operations (retries, logging, guardrails).
The part worth internalizing is what is not in there. None of those four jobs is hidden intelligence the model gets only through the framework. Every one is plain code you could write yourself. The real question is never “is the framework smart,” it is “should I hand this part over.”
Hand it over and you buy speed: a working agent on day one with a stack of nasty problems pre-solved. The cost is visibility. Your prompts, your tool calls, the exact text the model sees, all of it slides one layer back, behind the framework’s code, where you cannot watch it as closely.
The agent loop hiding inside every framework
Underneath every framework is a loop you could write in an afternoon. You send the model two things: the user’s request, and a list of tools it is allowed to call, each one just a name and the arguments it takes. The model replies. If it is a normal answer, you are done. If it is a request to use a tool, your code runs that tool, takes whatever comes back, and pastes it onto the end of the conversation. Then you send the whole thing again.
Call the model, run a tool, append the result, repeat, until it stops asking or a step cap makes it stop. That is maybe a hundred lines, no library required.
Do you need an AI agent framework?
Usually not to start, and the model makers agree. Anthropic’s own guide, Building Effective Agents, tells you to begin with direct API calls, because frameworks add layers of abstraction that can obscure the underlying prompts and responses and make the whole thing harder to debug. The company that makes the models is telling you to go easy on the abstractions.
That is a striking thing for a vendor to say, and it points at the cost of adopting a framework too early. You lose the thing you most need while learning: a clear view of exactly what your agent is doing and why it broke. You will learn more about how your agent really fails in one week of running a plain loop on real tasks than in a month of framework tutorials.
Why the framework question changed
The framework people were not wrong to build these. Back in 2023 they were fixing a real problem: the models were bad at this. Ask one for a clean block of JSON to trigger a tool and it might wrap it in chatter, misspell a key, forget an argument, or smother it in markdown that broke your parser. Early frameworks became scaffolding. They forced the output into shape, retried when it came back malformed, and covered for everything the model could not do alone.
Then the models got good. Tool calling went from a prompt-engineering trick to a native feature the providers built in. Context windows grew big enough to hold a long task without clever memory hacks. Planning several steps ahead became something the model just does. A lot of what those frameworks did for a living, the model now handles on its own.
The model mangled tool output: broken JSON, a misspelled key, a missing argument. The framework forced it straight and retried.
HELPSTool calling went native. Context windows grew. Planning got better. The work the scaffold did for a living, the model now just does.
NATIVEBolt the same brace onto a stronger model and it drags. One Anthropic trick that helped an older model turned into, in their words, dead weight.
DEAD WEIGHTAnthropic’s own context-engineering guidance makes this concrete: a trick that reset the context and clearly helped an older model became, in their words, dead weight once they moved to a stronger one. The help had turned into a drag. Scaffolding you build for last year’s model can be the exact thing holding this year’s model back.
The accidental framework: four walls every loop hits
So you start simple, the way everyone says to, and bring your clean loop to production. Then it hits a wall. Then another. Each wall has an obvious fix, and each fix is a part you weld on.
Forty-five steps into a fifty-step job the process dies and the whole history, sitting in memory, evaporates. So you save state after every step.
It gets stuck on a dead end, runs the same nothing twenty times, and you find out from the bill. So you add a budget and a hard step ceiling.
A second user shows up and their conversation leaks into the first, because one history array assumed one person. So you add per-user sessions.
You hand it a tool that can delete things and you do not want it deciding alone. So you add a gate where a human signs off before it fires.
Look at what you are holding now: state persistence, budget control, sessions, an approval gate, routing. That is the accidental framework, and it is the reason the “just build it yourself” crowd so often ends up with a worse version of LangGraph. Nearly every team that swears off frameworks rebuilds one by accretion, minus the docs, the tests, and anyone else who understands it.
But look back at the very first wall. The crash. It had nothing to do with whether the model was smart or dumb. It was about whether your run could survive being interrupted, and that is one of the oldest problems in plain distributed systems. It predates AI by decades.
Is a durable runtime the real first upgrade?
For a lot of teams, yes, and this is the reframe that makes the whole loop-versus-framework fight feel a little beside the point. To fix the crash, you do not reach up for an agent framework. You reach down, for a durable runtime underneath your loop: Temporal, DBOS, or Inngest. You keep your plain loop exactly as it is, run it on one of these, and when the server reboots mid-task it resumes from the line where it died with every variable intact.
This is not a fringe take. Anthropic hit the same wall building their research agents and said it plainly: agents are stateful, errors compound, and restarting from scratch is brutally expensive, so they built systems to resume instead. And the money is following the same logic. In February 2026, Temporal raised a $300 million Series D at a $5 billion valuation, betting that durable execution, not agent orchestration, is where the real production pain lives.
Should you build a multi-agent system?
Rarely, and almost never as early as people reach for it. The multi-agent swarm, a researcher handing to a writer handing to an editor, all chattering at each other, sounds great and mostly is not. Even the vendors whose product is multi-agent say so. Cognition, whose Devin is a multi-agent AI engineer, published one of the most-cited essays in the space, and the title is literally Don’t Build Multi-Agents.
Both Cognition and Anthropic trace the problem to the same root, and it is not the number of agents. It is context. Split a job across three agents and every handoff is a chance to drop information. Agent one summarizes a little badly, agent two builds on the gap, and the mistakes compound down the line like a game of telephone.
There is a narrow case where the swarm wins: work that is truly parallel and mostly reading rather than writing, where you fan out, gather a lot at once, and pull it back together. The second your agents have to share context or make decisions that lean on each other, one capable agent with a big context window tends to beat the whole committee.
AI agent framework vs loop: which should you pick?
Neither, as a default. Pick the smallest fix that clears the specific wall in front of you, and climb only when a wall forces it. The honest path is boring and it runs in order.
One model, a couple of tools, a step cap so it cannot spin forever. Ship it on real tasks before you add a single thing.
Buried in boilerplate for typed tools? Pull in something small like PydanticAI. A library, not a whole framework.
Need strict, auditable branching where step A must always run before step B? That is where LangGraph earns its keep.
Crashes losing work, runs lasting hours? Reach down for Temporal or DBOS so the job resumes instead of restarting.
Dead last, and only for the narrow case: work that is truly parallel and mostly reading, where agents never share context.
Match the fix to the wall, and nothing more. The table below is the same ladder read as symptoms, so you can find your wall first and pick the tool second.
| The wall you hit | Reach for | Not this |
|---|---|---|
| Nothing yet, just starting | A plain loop: 1 model, a few tools, a step cap | Any framework on day one |
| Buried in boilerplate for typed tools | A thin library like PydanticAI | A full orchestration framework |
| Strict, auditable branching (A before B) | A graph framework like LangGraph | Hand-rolled if-else routing |
| Crashes lose work; runs last hours | A durable runtime: Temporal, DBOS, Inngest | A framework bolted on top of the loop |
| Truly parallel, read-heavy fan-out | Multi-agent, and only here | Multi-agent for anything sequential |
There is a clean signal for when you have outgrown the loop. The day debugging a failed run takes longer than just shipping the feature would have, your hand-rolled loop has quietly become its own little platform, and a real framework is probably cheaper than babysitting it.
The bottom line
An AI agent framework is not magic and it is not a scam. It is four jobs of ordinary code you can either write or rent, bought at the price of seeing less of what your agent does. For most projects, the right first move is the boring one: build the ~100-line loop, run it on real work, and let the wall you actually hit tell you what to add.
When that wall arrives, fit the fix to it and stop there. Often the fix is not a framework on top at all, but a durable runtime underneath. Start with the loop, feel the wall, then go get the one piece that fixes it, and not a piece more. For the full walkthrough with every stage animated, watch the companion video below.
Watch the explainer
Frequently asked questions
What is an AI agent framework?
An AI agent framework is a library like LangGraph or CrewAI that wraps the model-and-tools loop and does four jobs for you: boilerplate for defining tools, state management, orchestration between steps, and operations like retries and logging. None of it adds intelligence the loop lacks; it is code you could write yourself.
Do you need an AI agent framework?
Usually not to start. A working agent is a roughly 100-line loop: send the model a request plus its tools, run the tool it asks for, append the result, repeat until it stops. Reach for a framework only when you hit a specific wall, like strict auditable branching, that the plain loop cannot handle cleanly.
Is an AI agent just a while loop?
Largely, yes. Call the model, run a tool in your own code, append the result to the conversation, and send it again until the model stops or a step cap trips. That cycle is about a hundred lines with no library. The interesting question is not the loop itself but how it holds up in production.
LangGraph vs CrewAI: which should I use?
Pick by the wall you hit. LangGraph suits strict, auditable branching where one step must always run before another. CrewAI leans toward role-based multi-agent teams. Before either, try the plain loop; most projects that reach for a framework on day one end up rebuilding a worse version of it anyway.
Should I build a multi-agent system?
Rarely, and almost never early. Splitting work across a researcher, writer, and editor drops information at every handoff, like a game of telephone. Multi-agent pays off only for truly parallel, read-heavy work where agents never share context. The moment they depend on each other, one capable agent usually wins.
What is a durable runtime, and why does it matter for agents?
A durable runtime like Temporal, DBOS, or Inngest sits under your loop and lets a run resume from the exact step it died on after a crash, with variables intact. Surviving interruption is an old distributed-systems problem, not an AI one, and it is often the real first upgrade an agent needs.
Sources
- Anthropic · Building Effective Agents (start with direct API calls; frameworks can obscure prompts and make debugging harder, Dec 2024) · retrieved 2026-07-09
- Anthropic · How we built our multi-agent research system (agents are stateful, errors compound, restarts are expensive, so build to resume, June 2025) · retrieved 2026-07-09
- Anthropic · Effective context engineering for AI agents (the smallest set of high-signal tokens; scaffolding for an old model can become dead weight) · retrieved 2026-07-09
- Cognition · Don't Build Multi-Agents, by Walden Yan (context engineering, single-writer principle) · retrieved 2026-07-09
- Temporal · Raises $300M Series D at a $5B valuation to make agentic AI real (durable execution, Feb 2026) · retrieved 2026-07-09
- Pydantic · PydanticAI v1, a type-safe Python agent framework (v1 shipped September 2025) · retrieved 2026-07-09
The newsletter
Liked this? Get the Take-Outs.
One email every Tuesday: a spicy take on a trending dev topic, video out-takes, and the tool of the week. Free.