Agent Harnesses Explained

/learn

How a harness turns a model into an agent

One chapter per mechanism, each opening with an animation. Every frame is computed by the Agent_Loop_Sim engine (checked against its Python reference), and every token count comes from a real tokenizer. Toggle layers (Concept / Maths / Code) inside any chapter to choose how deep to go. For the slides behind each chapter, see the Agents and Coding Agents series.

  1. Model, tool call, result, model again: the loop a harness runs, and the context window filling as it goes.

  2. JSON Schema in, a structured call out: what the model actually sees and writes, natively and as ReAct text, and what happens when a call is malformed.

  3. System prompt, tools, history and tool results share one window; when it fills, truncation, clipping or summarising decide what is kept and what is lost.

  4. A stable prefix is read from the cache at a tenth of the price; a timestamp or a reordered tool list breaks it.

  5. Allow, ask and deny rules evaluated against every call; each question to the human adds their thinking time to the run.

  6. A parent hands a sub-task to a child with a fresh context and gets a short report back: a smaller context for the parent, paid for in the child's tokens and in time.

  7. Hooks intercept every call before and after it runs; a sandbox bounds what a shell command can reach, whatever the rules allowed.

  8. Tools fail: retries with back-off, errors fed back to the model, and loop detection, with the success rate against the retry budget from seeded runs.

  9. How Claude Code, Codex CLI, Aider, OpenHands, SWE-agent and mini-SWE-agent make each choice, from their docs, and the same task under a policy imitation of each.

  10. Tokens per turn, the cache, output speed and human waits: the full arithmetic of a task, with a live calculator driven by the engine.