GuideAdvanced
Long-Running Agents: the Harness
An agent that answers a question fits in one session. One that builds a project does not: it works for hours or days, across many sessions, and each session starts without remembering anything about the last one. This guide teaches you to build the **harness**, the system around the model that makes that long work possible: who defines what "done" means, what gets written down between one session and the next, what happens when the process dies halfway, who decides that a feature passes, how much the agent can spend and what it can touch, how the conversation stays inside its context budget, and how you read afterwards what happened. You learn it by building the harness that gets an agent to write **ratecard**, the shipping quote package for Brindle Freight, a fictional parcel company: an initializer agent turns the spec into a feature list with acceptance tests; twelve coding sessions move one feature at a time, with a fixed startup routine, a progress log and a commit at the end; a checkpoint after every step lets you kill the process and resume without sending the same notice twice; a verifier rejects the feature the agent calls done without testing, or that breaks one that already passed; budgets, approvals and the sandbox bound what the agent can do alone; and a trace with a logical clock lets you follow one feature across sessions and replay a whole session without calling the model again. All the code runs on your laptop without an API key, with a deterministic simulated model that has the same response shape as the Claude Messages API and that makes, when you ask it to, the mistakes Anthropic documents in "Effective harnesses for long-running agents": declaring done without testing, touching the test, getting stuck, trying to leave its folder. You see the same numbers as the guide. An optional `--live` mode uses the real API. Every piece is connected to its equivalent in the Claude Agent SDK and the OpenAI Agents SDK, cited from their documentation.
- 64
- lessons
- 8
- modules
- English · Spanish
- available in
- Free
- access
Outcomes
What you'll be able to do
- Explain why a single session is not enough for long work and which piece of the harness prevents each failure
- Write an initializer agent that leaves a JSON feature list, acceptance tests, a smoke test and the first commit, and protect that list from changes
- Design the startup routine, the progress log and the clean-state close of every session, with git as history and as undo
- Save a durable checkpoint after every step and resume after a crash without repeating external effects, using idempotency keys
- Put the decision of "done" outside the model: its own test, a regression check, and tests the way a user would run them
- Set budgets for turns, tokens and dollars with an orderly wrap-up, human approvals, escalation when the agent gets stuck, and a sandbox for paths and commands
- Keep a long session inside its context budget by clearing old tool results and compacting, with the important memory in files
- Instrument the harness with a reproducible trace, read it by session and by feature, replay a session without a model, and measure the health of a run
Before you start
What you need to bring
It's for you if...
- Engineers who already built an agent with tools and need it to work much longer without losing the thread
- Platform engineers who will run coding or research agents in the background, for hours, on real projects
- Tech leads who have to decide how much autonomy to give an agent and how to know what it did
Requirements and materials
- Intermediate Python: functions, `dataclass`, dictionaries, JSON, `subprocess`, running a module with `python3 -m`
- Having seen an agent loop with tools (`tool_use` and `tool_result`). The guide reviews it in full
- Basic Git (commit, log). Docker is optional
- Python 3.10 or newer and `git`. No API key needed; for the optional `--live` mode, an Anthropic key and `pip install anthropic`
Content
The syllabus, module by module
Open any of them to see its lessons.
- 1. Introduction: an agent that works in shifts
- 2. Why one session is not enough
- 3. Anatomy of a harness
- 4. Lab, part 1: state, journal, sandbox, verifier, context and trace
- 5. Lab, part 2: the mock and the `--live` mode
- 6. Lab, part 3: tools, loop and runner
- 7. The naive agent
- 8. Project: diagnose the naive run
Common questions
What people usually ask
No limit. It's a free guide: come in whenever you like, as often as you like.
No. Modules run from easier to harder, but you can jump to the one you need. Progress is saved per lesson.
Whatever is needed is listed under “What you need to bring”, above. If nothing is listed there, you can start from zero.
In the WhatsApp group, and every two weeks there's a live with an instructor where questions get worked through.
Start whenever you like
What students say
These reviews are from enrolled students who completed at least 50% of the course. We moderate reviews only on content grounds (spam, offensive language, personal data), never for being critical or negative.
No approved reviews yet.
Be the first to share your experience!