1In one sentence
An agent is Claude running in a loop (think, use a tool, look at the result, repeat) until a job is done, and there are three ways to build one, from most to least work.
2New words
- Agent — Claude with tools and a goal, working through steps on its own. Cowork and Claude Code are agents Anthropic built; you can build your own.
- Agent loop — the cycle: Claude decides, calls a tool, reads the result, decides again. It ends when Claude says the job is done or a limit is hit.
- Agent SDK — a library (Python or TypeScript) that gives your program the same engine Claude Code uses: tools, permissions, sessions, helpers, hooks, MCP, skills.
- Managed Agents — Anthropic hosts the agent for you: the loop, the sandbox (a safe computer it works in), memory, scheduling. You send tasks and read results.
- Sandbox — an isolated computer where the agent can run code and files without touching anything else.
3Why you would want it
A chatbot answers questions. An agent clears a backlog: reads every support ticket and drafts replies, checks a site nightly, keeps a report updated. The three options let you choose how much you want to own.
| Option | You write | Anthropic provides | Best for |
|---|---|---|---|
| Your own loop (Client SDK) | The loop, tool execution, safety | The model and the API features | Full control; small focused agents |
| Agent SDK | Your tools and rules | The whole engine from Claude Code | Agents inside your own product or servers |
| Managed Agents | A description of the agent and its tools | Hosting, sandbox, memory, scheduling, multi-agent orchestration | Long-running or unattended work, fast to launch |
4Try it now
(developer account; Claude Code helps)
- Ask Claude Code: Using the Agent SDK, build a tiny agent that reads every file in a folder and writes summary.md with one line per file. Limit it to reading and writing in that folder.
- Run it on a folder of ten files. Read summary.md.
- Add one rule: Ask before writing if summary.md already exists.
5What you will see
[Picture pending: the agent's run log and the summary file.] A short program; when run, a log of each step (reading file 1, 2, ...) and the finished summary. Managed Agents show the same as a session you can watch in the console.
6Watch out
- Give every agent limits: which folder, which tools, how much it may spend, when to ask. An agent without limits is a loop without an end.
- Start with read-only agents. Add writing, sending and buying only after you have watched many runs.
7Go further
Give the agent a schedule (Chapter 6.9) and it becomes a colleague who works nights. Chapter 6.10 is the safety and cost chapter you read before letting it.
