Building without a framework
An agent is a loop around a model API. Start with plain API calls, learn what a framework would add, and adopt one only when it earns its abstraction.
Start with the loop
Anthropic’s guidance after working with many teams is that the most successful agent implementations used simple, composable patterns rather than complex frameworks1. They suggest starting with direct calls to a model API, since many patterns take only a few lines of code1.
The core of an agent is small: send messages and tool definitions to the model, run whatever tools it requests, append the results, and repeat until it stops asking. See The execution loop and Tool calling for the details.
Diagram: my own.
Writing this yourself once is worthwhile. You will see exactly what is sent to the model, which makes later debugging far easier.
What a framework can supply
Diagram: my own.
Anthropic notes that frameworks make it easier to get started by handling standard low-level work such as calling models, defining and parsing tools, and chaining calls. The catch is the extra layers of abstraction that can hide the underlying prompts and responses, making debugging harder, and the temptation to add complexity when a simpler setup would do1. If you do use one, they advise making sure you understand the code underneath, because wrong assumptions about what is under the hood are a common source of error1.
That post is from late 2024, and Anthropic has since added a note that much of the tooling landscape it describes has changed1. The principle is stable; the product names are not.
What you actually need to build
Check each against your project before reaching for a framework:
- The loop with a hard stop. Maximum turns, tokens and time (Stopping conditions).
- Tool definitions and error handling. Return errors the model can act on (Tool design).
- State. Where messages and results live between calls, and how to resume (State and checkpoints).
- Tracing. Log every model call and tool call (Tracing and monitoring).
- Approvals and limits. Gate risky actions (Human approval).
If you need little beyond points 1 and 2, you may not need a framework. If you need durable resumption, multi-agent coordination, built-in tracing and approvals, a framework or SDK saves real time.
A middle path: SDKs that package a harness
Some SDKs are less like frameworks and more like a ready-made harness. Anthropic’s Agent SDK, for instance, packages the agent loop, built-in tools and context management that power Claude Code as a library you embed in your own application2. You trade control of the loop for a tested one. See Claude Agent SDK.
Decision rule
Start plain. Move to a framework when you can name the specific capability you would otherwise build, and when you have read enough of its source or docs to know what it sends to the model. Compare options in Choosing a framework.
Sources
- [1]Building effective agents — Anthropic · 2024PARAPHRASED
- [2]Agent SDK overview — Anthropic, Claude Code docsPARAPHRASED