Topic 1 of 5 · 4 min read
When an agent framework earns its place
Goal: Decide whether a framework saves real work for a described project or only adds abstraction, naming the features that tip it.
Use an agent framework when it removes work you would otherwise write and maintain yourself, not because every agent tutorial uses one. A framework is a library that runs the agent loop for you. The loop is simple: call the model, run the tools it asks for, feed the results back, repeat until it stops.
Check yourself · 1 of 3
What does an agent framework mainly run for you?
What a framework gives you
- The loop, with a turn limit and stop conditions.
- Tool plumbing: turning a function into a JSON schema, validating the model's arguments, catching exceptions and returning them as tool results.
- State: conversation history, sessions that can be resumed, and sometimes checkpoints that survive a crash.
- Tracing: a record of every model call and tool call, usually with a viewer.
- Handoffs and subagents: one agent passing work to another with its own prompt and tools.
- Guardrails and approvals: checks on input and output, and a pause for a human to approve a risky call.
What it costs
Every framework adds a layer between you and the model. When the agent misbehaves, you must work out whether the fault is in your prompt, your tool, or the framework's own prompts, retries and message formatting. You also take on its version changes, its concepts to learn, and its limits on what you can customise.
How to decide
Ask these questions about your project:
- Does it need durable state: a run that takes hours, survives a restart, or waits days for a human? Building checkpoints yourself is real work. That tips toward a framework such as LangGraph.
- Does it need many agents or handoffs? Hand-rolled routing gets messy fast.
- Does it need traces for a team? A built-in viewer beats printing logs.
- Is it one agent with three tools and a single model? A plain loop of under a hundred lines may be clearer and easier to debug.
Before and after
Weak reasoning: "We are building a support bot, so we need an agent framework." The bot looks up an order and drafts a reply. That is two tools and a short loop, and the team has never debugged the framework's prompts.
Better: "We start with a plain loop and a logging wrapper. We adopt a framework if we need resumable runs or handoffs." The team keeps the option, pays nothing now, and knows exactly what the framework would replace.
What goes wrong
- Adopting for the demo. The quick-start works in ten lines, then production needs retries, timeouts and a custom prompt, and you fight the abstraction.
- Hidden behaviour. The framework adds instructions or retries you did not write, and you cannot explain a surprising answer.
- Rewrite pressure. The framework changes its API twice in a year and every upgrade breaks your agent code.
- Refusing frameworks on principle. Rebuilding checkpointing, tracing and approvals by hand is slow and tends to be worse than the library.
Anthropic's own guidance on building agents advises starting with direct API calls, because many patterns take only a few lines of code, and warns that extra layers can obscure the prompts and responses you need to debug.
Examples
Two projects, two answers
Project one: an agent that reads a ticket, calls lookup_order and refund, and replies. One model, two tools, runs for under a minute. A plain loop with a turn limit and a log file does the job.
Project two: a research agent that runs for six hours, splits into five subagents, and pauses for a manager to approve spending. It must resume after a deploy. Building checkpoints, handoffs and an approval pause by hand is weeks of work, so a framework with persistence earns its place.
Reading the cost
A team adopts a framework and finds that answers got worse after a minor upgrade. The cause was a changed default instruction inside the library, not their prompt. Nobody noticed because they had no raw request log. The lesson is not that frameworks are bad. It is that you pay for the abstraction in debugging time, so keep a way to see what was sent.
Key points
- A framework runs the agent loop, tool plumbing, state, tracing and handoffs so you do not write them.
- Every framework adds a layer that can hide prompts, retries and message formats when you debug.
- Durable state, multi-agent handoffs, human approvals and team-wide tracing are the features that most often justify one.
- One agent with a few tools and one model often runs best as a plain loop you fully understand.
- Decide from the features the project needs, not from what tutorials use.
Common mistakes
- Picking a framework before listing what the project needs.
- Judging a framework by a ten-line quick-start instead of a failing production run.
- Assuming a plain loop is always better, then rebuilding checkpoints and tracing badly.
- Upgrading the framework without reading what changed in its default prompts.
Check yourself · 2 of 3
Which project most clearly justifies adopting a framework with durable state?
Check yourself · 3 of 3
What is the main cost of putting a framework between you and the model?
Practice items, not counted towards your mastery.
Start here
- Agent SDK overview (Claude docs) (opens in a new tab)DocsFree
The built-in tools, sessions, hooks and subagents of Anthropic's agent SDK.
- OpenAI Agents SDK (opens in a new tab)DocsFree
Agents, handoffs, guardrails and tracing as the SDK defines them.
- LangGraph overview (opens in a new tab)DocsFree
Graph-based orchestration with durable state, checkpoints and human-in-the-loop.
More for this topic
- Building effective agents (Anthropic) (opens in a new tab)ArticleFree
Advice to start with plain API calls and warns that frameworks can hide prompts and responses.