What is the agent harness?
Why the model and the agent are different things. The harness owns tools, context, permissions, execution and the loop.
The model is only one part of an agent. Everything else — the loop, the tools, what goes into each request, what is allowed to run — is ordinary code wrapped around the model, usually called the harness. This lesson draws the line between the two and names what the harness is responsible for.
The model is one part of the agent
A model is a stateless function: given some text it returns some text, and sometimes a request to call a tool. It runs nothing, remembers nothing between calls, and decides nothing about what happens next. The program wrapping it is the agent, usually called the harness, and that is where almost everything that makes the system act like an agent lives. So the model and the agent are different things, and keeping them apart is what shows where the real work is: in the harness, not the model.
Read
The harness controls everything the model sees
The model's only input is the text of one request, so what it does is decided by what the harness puts there. One well-known way to put this is that an agent's behaviour is fixed by five things the harness sends: the system prompt, the tool descriptions, the user prompt, the tool results, and any reminders it inserts. Give a second agent those same five inputs and it produces the same output. Building an agent is therefore mostly a matter of deciding what goes into each request and reading what comes back; the model underneath can be swapped without changing what the agent is.
Read
What the harness owns
Each of the harness's responsibilities is a decision the model does not make. The harness owns which tools exist and how they are described (the registry from lesson 4); what goes into the conversation and what is left out (the context); what is allowed to run and what needs a human first (permissions); how a tool call is actually carried out and its result captured (execution); and whether the loop takes another turn or stops. The model proposes an action; the harness is what decides, enforces, and runs it. These five responsibilities are the seams the rest of the course works on, one lesson at a time.
Read
Pulling the harness into named parts
In lesson 2 all of these jobs sat in one loop function. Splitting them up means giving each a name and a boundary: a model client that is the only part that talks to the API, an agent state that holds the conversation, an executor that runs one tool call, a loop that drives the turns, and the tool registry from lesson 4. This adds no new behaviour — the run is identical to lesson 2 — but each job becomes a part you can change on its own, which is what the later lessons build on. The loop itself is a small, well-understood piece of code, so most of the design work is in the parts, and how elaborate they need to be depends on what the agent is for.
Read
My notes
- powerful new models are making harnesses obsolete over the last few years. For example CoT used to be a well-established pattern until reasoning models came (RL on CoT traces)
- the Kirby effect: every component in a harness encodes an assumption about something the model cannot do on its own
Build — write the agent
Tiny Agent v0.2 reaches its final shape here, and it changes how the agent is wired, not what it does. In lesson 2 a single loop function did everything: it called the model, ran the tools, grew the conversation, and checked the stop condition, all in one place. This lesson pulls those jobs apart into named parts, each owning one of them, so the model and the agent stop being the same thing. A `ModelClient` becomes the only part that talks to the API; an `AgentState` holds the conversation; an `Executor` runs one tool call and turns a failure into a result the model can read; an `AgentLoop` is the control flow that drives them and decides when to stop. The `Registry` from lesson 4 is the fifth part. No new capability — the run is identical to lesson 2's — and that is the idea: the same behaviour, now assembled from parts you can name, inspect, and change one at a time.
Provided for you — don’t edit these
agent/v0_2/registry.py— theToolandRegistryyou wrote in lesson 4; the harness's fifth part, carried in as-is.agent/v0_2/tools.py— the three tool bodies (list_files,read_file,edit_file), carried forward from v0.agent/v0_2/__main__.py— the runner. It builds the registry, then assembles the five parts and runs the loop. You should not need to edit it.
To do
agent/v0_2/client.py—ModelClient, the only part that talks to the API. It sends the conversation through the recorder and returns the raw response.agent/v0_2/state.py—AgentState, the conversation: seed the opening message, then append the model's replies and the tools' results.agent/v0_2/executor.py—Executor, which runs one tool call through the registry and catches a failure as an error result rather than letting it kill the run.agent/v0_2/loop.py—AgentLoop, the control flow: ask the model, run the tools it asked for, stop when it is done or the turn limit is hit. The recipe for each is in the file's docstrings.
Run it
uv run --env-file .env python -m agent.v0_2When you run it, the agent fixes the same misspelled greeting as in lessons 2 and 4, and the trace below is the very same run the lesson-4 page shows — because decomposing the loop is a refactor, not a new capability. Nothing the reader can observe changes; what changes is that each responsibility now lives in a part with a name, which is what the rest of the course builds on.
The greeting printed by this package is misspelled. Find the file it lives in, fix the spelling, and tell me what you changed.