← The Agent Lifecycle
Foundational

The Agent Harness: Everything Around the Model That Decides Whether an Agent Works

An agent is a model plus a harness: the loop that calls it, the instructions it loads, the tools it may use, the permission checks and sandbox around those tools, the log and memory that survive the run, and the verifier that decides when it is done. Two products on the same model can differ widely because of the harness, and many harness choices are product decisions.

CONCEPT / THE AGENT LIFECYCLE

TL;DR: The harness is the software around a model that turns it into an agent: it loads instructions, assembles context, calls the model, checks whether the chosen action is allowed, runs it in a sandbox, records the result, keeps the context window under control, verifies the work and decides when to stop. Two agents built on the same model can differ widely because their harnesses do. A PM owns the parts that encode product judgment: what counts as done, what the agent may do without asking, how much it may spend, and what is kept when the run ends.

Model plus harness

Ask why one coding agent finishes a task and another, on the same model, wanders off. The answer is rarely the model. It is what the model is shown, which tools it gets, whether a failing test sends it back to work, and whether anything stops it from deleting the wrong directory.

Vendors now ship harnesses as products. Anthropic describes its Agent SDK as giving developers "the same tools, agent loop, and context management that power Claude Code". OpenAI's Agents SDK offers a deliberately small set of parts: agents, handoffs between them, guardrails and tracing. Both treat the loop the same way: the model evaluates the task, calls tools, receives the results and repeats until the task is complete.

Anthropic's engineers put the design principle in one sentence: every component in a harness "encodes an assumption about what the model can't do on its own". That makes the harness a list of bets about the model's weaknesses, and those bets expire. A planning step that a weaker model needed may only slow down a stronger one. Re-test the harness when the model changes, not only the model.

Nine jobs on every turn

EXPLORE THE FLOW
What the harness does on every turn of the loop WHAT THE MODEL SEES WHAT THE AGENT MAY DO WHAT SURVIVES THE RUN WHEN IT ENDS until done or out of budget 1 Load instructions AGENTS.md, system prompt, skills 2 Assemble context history, retrieval, tool results 3 Call the model plan, answer or choose a tool 4 Check permission policy, hooks, classifier, human 5 Run the tool inside a sandbox 6 Record the result append to the session log 7 Manage the context compact or write to files 8 Verify the work tests or a separate evaluator 9 Stop or continue done, out of budget, or ask Codex reads AGENTS.md before any work; the nearest file wins on a conflict. Anthropic reports its auto-mode classifiers miss 17% of real overeager actions (company-reported). Keep credentials out of the sandbox where generated code runs. Compaction summarises old history. Multi-session work also needs a progress file and git commits A separate, skeptical evaluator was easier to tune than self-critique in Anthropic's tests.

Follow the flow, one stage at a time.

Illustrated sequence; animation speed does not represent processing time.
Read diagram description

The harness loads instructions, assembles context, calls the model, checks permission for the chosen action, runs the tool inside a sandbox, records the result in the session log, manages the context window, verifies the work and decides whether to stop. Until the task is done or the budget runs out, it loops back to assembling context.

JobWhat it decidesThe product question
InstructionsWhat the agent knows about this project before it startsWho maintains the instruction file, and is it reviewed like code?
Model callWhich model, at what effort, with which tools offeredIs this step worth a larger model or more reasoning?
Context assemblyWhich history, documents and tool results the model seesWhat is the agent missing when it fails?
Permission checkWhether this action runs, waits for a person, or is refusedWhich actions are safe to run unasked?
SandboxWhat a running tool can touchIf the agent goes wrong, what is the worst it can reach?
Session logWhat happened, in orderCan we replay and audit a run?
Context managementWhat to drop or summarise as the window fillsWhat must survive a long run?
VerificationWhether the work meets the barWho or what says "done"?
StoppingDone, out of budget, or needs a personWhat does a run cost at most?

Sandbox and approval are different controls

It is tempting to treat "the agent asks before acting" as the whole safety design. OpenAI's Codex documentation separates the two controls cleanly: "The sandbox defines technical boundaries. The approval policy decides when the agent must stop and ask before crossing them." Claude Code's permission modes run from asking for every edit, through accepting edits, to an automatic mode, and reserve the mode that skips all checks for isolated containers and virtual machines. Deny rules apply in every mode.

Asking is weaker than it looks. Anthropic reported in March 2026 that users accepted 93% of Claude Code's manual permission prompts, which is a sign that many approvals are reflexive. It replaced some prompts with model-based classifiers and published their error rates: a false-positive rate of 0.4%, and a false-negative rate of 17% on real overeager actions (company-reported).

Read those numbers as a PM. If an agent attempts 50 overeager actions a week across a team, a 17% miss rate lets about 8 through. Neither a tired human nor a classifier is a guarantee, so the sandbox has to make the misses survivable: no production credentials inside it, writes limited to a working copy, network access allowlisted. Anthropic's managed-agent design states the rule directly: credentials are "never reachable from the sandbox where Claude's generated code runs". Pair this with the tool execution envelope, which covers idempotency and limits per tool.

Context that survives a long run

A single context window cannot hold a day of work. Harnesses compact: the Agent SDK summarises older history automatically as the window nears its limit, keeping recent exchanges and key decisions. For work that spans many sessions, Anthropic found that "compaction isn't sufficient". Its long-running harness adds an initialiser that writes a setup script, a progress log and a first git commit, and a working agent that makes incremental progress and leaves clear artifacts for the next session. The failure it prevents is specific: a fresh session sees partial progress and declares the job done.

The product lesson: decide what the agent must write down, in a file a person can read, so that a restart, a handoff or an audit does not depend on the model's memory. See context engineering for the per-call budget and agent memory for what persists across tasks.

Verification is the expensive part

A model asked to grade its own work tends to approve it. Anthropic reported that tuning "a standalone evaluator to be skeptical" was far easier than making the generator critical of itself, and published a cost comparison for one application build: about 20 minutes and $9 for a single agent, about 6 hours and $200 for the full planner, generator and evaluator harness (company-reported, one task). Anthropic describes the full architecture as producing rich full-stack applications over multi-hour sessions. The PM decision is which tasks justify that kind of spend, and the answer comes from the cost of a wrong result, not from enthusiasm for agents. In June 2026 Anthropic also added workflows in which the model writes its own harness for a task, noting that they use more tokens and suit complex, high-value work.

What the PM owns

  1. The definition of done. A test suite, a rubric or a reviewer, written before the agent runs. Without it, the verifier step has nothing to check.
  2. The permission policy. Which actions run unasked, which wait, which are refused, by reversibility and blast radius.
  3. Budgets. Tokens, wall-clock time and tool calls per run, with a defined stop, as in budgets and loop control.
  4. The record. What the session log keeps, for how long, and who can read it.
  5. Harness experiments. Hold the model fixed and change one harness component at a time, measured on the same task set used for model comparisons. A harness change can move success more than a model upgrade, and it is far cheaper to test.

In the interview

Agent design rounds now probe the harness directly: "our agent fails on long tasks", "it deleted a file it shouldn't have", "the same model does better in a competitor's product". A weak answer reaches for a bigger model. A Hire answer adds tools or a human approval. A Strong Hire answer names the harness component at fault, separates sandbox from approval, prices verification against the cost of an error, makes the agent write its progress down, and proposes an experiment that changes one component while holding the model fixed.

Next: context engineering and budgets and loop control. The Premium guide Harness Engineering for PMs goes chapter by chapter.

RELATED CONCEPTS
PRACTISE THIS CONCEPT