9 min read

Harness Engineering, or Agent = Model + Harness

Harness Engineering, or Agent = Model + Harness

An agent is a model plus a harness. What does the harness do, which part is yours to build, and why does it get thinner as models improve?

This article is part of a series on AI coding agents' "XXX engineering" terms. Its thesis: each new term (prompt → context → harness → loop → ... graph?) adds a ring around the last one instead of replacing it, and each article asks where the human sits. Find the other articles in the series:

  1. "AI Coding Agents: From Writing Prompts to Designing Systems"

  2. "Harness Engineering, or Agent = Model + Harness" (this article)

  3. "Loop Engineering, or Sit on the Loop, Not in It" [coming soon, working title]

  4. "After Loop Engineering: Is Graph Engineering the Next Ring?"

  5. "Who Coined What: The Origins of the Agent-Engineering Terms" (companion article)

Five nested rings around the model: the harness is the third

On February 17, 2026, LangChain lifted its own coding agent from 52.8% to 66.5% on Terminal Bench 2.0, from outside the top 30 to the top 5, by changing only the harness and keeping the same model. (LangChain sells harness tooling.)

Seven months later, the numbers point the other way. In September, when a team from UC Berkeley and Arena ran one frontier model through Claude Code, Codex CLI or Pi, the harness moved its success rate by about two points on one benchmark and five on the other, while the cost per task varied up to five times. In October, Liu and Han found Claude Code and mini-SWE-agent, a harness of about 100 lines of Python, equivalent within five points on two open models.

Jediah Katz, Cursor's longest-tenured agent-harness engineer, now building Grokbot at SpaceX, summed up the shift well at AI Engineer on October 19:

"A fancy harness in this day and age no longer adds coding intelligence." — Jediah Katz (5:43)

His next question is whether the harness is dead, and his answer is no: it opens new kinds of work, and part of its job can never move into the model.

Harnesses were central and decisive at first; they are getting thinner, but they still have an important role to play.

Harness = everything that isn't the model

What a harness does

A harness turns a model into an agent: it gives the model its context and its tools, runs the actions the model asks for, and feeds the results back.

Vivek Trivedy, at LangChain, put it as a formula on March 10: Agent = Model + Harness. His rule for telling them apart: "If you're not the model, you're the harness."

What's inside a harness

A harness is made of system prompts, tools, skills, a sandbox, hooks and, more recently, extensions (mods) that run around each model call. On every turn, it:

  • Assembles the context window from what is available: AGENTS.md or CLAUDE.md, docs, the message history, and the prompts, skills and tool definitions above;

  • Calls the model;

  • Runs the tool calls the model asks for, in a sandbox and within the permissions it was given;

  • Feeds the results back;

  • Trims the history when the window fills up.

It repeats until the model stops asking for tools and gives its final answer: the agent says it is done. That cycle, inside one session, is the harness at work. What starts the next session, with no human prompting in between, is the loop, the subject of the next article.

One turn of the harness. Adapted from Anthropic, "Effective context engineering for AI agents", September 29, 2025

Inner harness and outer harness

A harness is made of two parts, usually built by different teams:

  • The inner harness: what the vendor (or your inner harness team) ships and you mostly leave alone: the cycle that calls the model and runs its tool calls, the built-in tools, context handling, permissions, the sandbox. Claude Code, Codex, OpenCode and Pi (and what you build with it) are inner harnesses;

  • The outer harness: what you add so the agent does your context-specific work well, again and again: AGENTS.md or CLAUDE.md, skills, hooks, linters, tests.

Birgitta Böckeler draws the same split on martinfowler.com, as a "builder" harness and a "user" harness in rings around the model. In this series' rings, prompt and context sit between the model and the harness, so the split divides the harness ring in two, as the diagram below shows.


The inner harness usually comes from the vendor; the outer harness is yours

The line between the two has recently started to move. Pi was made to let you build your own inner harness from scratch: TypeScript extensions reach its tools, events and message history. Claude Code now also has mods: JavaScript or TypeScript handlers that can watch, rewrite or take over a tool call, a prompt or a request. So part of the inner harness is now yours to change.

Build your own inner harness only if you can measure the gain

Most teams run the inner harness that their vendor or provider ships. Some build their own, as LangChain did, to control every step of the cycle.

On the same model, the best harnesses score alike, except on cost

The two autumn studies cited above compared shipped inner harnesses, one on frontier models and one on open models:

  • HarnessTax ran seven models through Claude Code, Codex CLI and Pi. Claude Fable 5 solved 97.8% of tasks in Claude Code and 96.7% in each of the other two, while a task cost $1.33 in Claude Code against $0.67 in Pi. In 9 of 12 comparisons, the best score did not come from the harness of the model's own vendor (Claude Code for a Claude model, for example);

  • Liu and Han ran each pairing of model and harness several times. On 45 hard tasks, changing the harness changed the result, pass or fail, as often as running the same harness twice, which means that the harness made no more difference than chance.

A larger test in November, ten harnesses on three open models with three attempts per task, found the top five statistically tied.

Liu and Han find that what a task costs is mostly the input sent at each step, multiplied by the number of steps, and that the harness changes both: on one open model, a task cost 1.81 yuan in Claude Code, 0.97 in mini-SWE-agent and 0.56 in OpenCode.

Cost per task by inner harness, same model and same tasks (Liu and Han, October 2026)

One caveat on these studies, though:

  • HarnessTax ran only 30 tasks per benchmark, and Liu and Han's hard set has 45: too few to detect a small difference;

  • Both studies used public benchmarks that the models may have seen in training.

A custom harness pays off when the model is constrained

Both studies compare harnesses as their vendors ship them: neither tests a harness tuned to a particular situation or kind of work. Yet for a limited or constrained model, for example, a tuned harness can bring sizable gains:

The price is upkeep: Cursor spends weeks tuning its harness for each new model. And a gain already won must be confirmed again each time, by rerunning the evals.

On a frontier model and standard tasks, a shipped inner harness does not necessarily score better than another. Even if one can cost two to five times as much per task as another, that alone does not justify the cost and upkeep of a custom harness. So if you do want to build your own inner harness, do it where your constraints or your work differ significantly, and only if you can measure the gain.

Build your outer harness for what the agent can't work out alone or efficiently

Whatever inner harness you run, the outer harness is yours to build. Mitchell Hashimoto builds his empirically: each time it gets something wrong, he takes the time to "engineer a solution such that the agent never makes that mistake again."

OpenAI's Ryan Lopopolo shows what putting such "solutions" in place looks like on a product of about a million lines. The team's AGENTS.md is about 100 lines, a table of contents for a docs/ folder that linters, CI and a recurring agent keep up to date: "give Codex a map, not a 1,000-page instruction manual."

Steer the agent before it acts, redirect it after

Böckeler sorts the pieces of an outer harness into two kinds:

  • Guides steer before the agent acts: AGENTS.md, a skill, an API specification;

  • Sensors (also called backpressure) observe after it acts, so it can correct itself: tests, linters, an AI review.

A lint message that carries its fix is what she calls "a positive kind of prompt injection".


Guides and sensors, deterministic or AI-judged (after Birgitta Böckeler)

Point to the practices specific to your project and organization

What is worth adding to the outer harness is what the agent cannot work out from the code itself. ETH Zurich researchers found that context files do not generally raise task success and add over 20% to inference cost, whether a model or a developer wrote them; what does help is instructions on non-standard practices. Anthropic gives the same advice for Claude 5 models: spend CLAUDE.md on your project's quirks, not on what the model already knows.

In practice:

Often useful on a small model, mostly costly on a large one

An outer harness has a cost too, so measure it. Naresh Jain (founder of Specmatic, the tool his harness uses) ran the same task ten times with and without an outer harness, made of API specifications, examples and a skill as guides, and tests against those specifications as sensors:

  • Frontier model (GPT-6 Sol): 10 out of 10 runs either way, but the harness used about 10 times the tokens and 7 times the cost;

  • Cost-optimized model (GPT-6 Luna): 3 out of 10 without the harness, 10 out of 10 with it, and still a third cheaper than the frontier model without one.


Same task, ten runs each, with and without an outer harness (Naresh Jain, October 2026)

Jain's test is a special case, as it uses only one new Java service, with an unusually detailed brief. Even so, its lesson still holds: check, for each model, which pieces of your harness are still worth their cost. Fan and co-authors, cited above, point the same way: predefined tools help the small models, while the largest does better, at half the cost, with bash alone.

This is where the human sits. Böckeler puts the job in one line: "steer the agent by iterating on the harness." One part cannot be handed over: no sensor can judge whether the code is correct if nobody said what correct means.

How harnesses evolve

Early 2026: the harness augments the models

LangChain's February gain came from pieces that did what its model did not do alone: a checklist that made the agent verify its work against the spec before stopping, a nudge when it kept editing the same file. Of these last guardrails, Trivedy wrote: "As models improve, these guardrails will likely be unnecessary."

Prithvi Rajasekaran, at Anthropic, wrote in March that each component of a harness "encodes an assumption about what the model can't do on its own." His example: the model Claude Sonnet 4.5 tended to wrap up its work early as its context window filled, so his harness reset the context; with Opus 4.5 that behavior largely went away, and so did the resets. His advice: when a new model lands, strip what is no longer needed and add what has become possible.

Autumn 2026: models have absorbed what harnesses gave them

By autumn, exploring the codebase and running tests to check the work were skills that models, by Katz's account, had absorbed. That would explain what the two autumn studies measured.

Katz explains why these pieces stop being needed, with what he calls the data flywheel:

  • A harness makes a harder task feasible;

  • People start doing that task with agents;

  • That work reaches the labs as training data;

  • The next model learns to do it on its own;

  • The harness deletes the pieces it added for that task.

Vendors are doing exactly that to their own harnesses. At Cursor, the late-2024 guardrails, such as lint checks after every edit and a cap on tool calls per turn, are "mostly long gone", Stefan Heule and Katz wrote in April. Anthropic cut over 80% of Claude Code's system prompt for its Claude 5 models, with no measurable loss on its coding evaluations.


The data flywheel: what the harness patches today, the model learns tomorrow (after Jediah Katz)

Next: what is left for the harness?

The harness moves on to what models cannot yet do alone. At SpaceX, Katz's team is adding prompts and guardrails back to Grokbot for new kinds of work (Grokbot is his product, so read that as a pitch).

Some of the harness can never move into the model, Katz says: where the agent runs, what it is trusted with, and what it costs. The rest will keep changing. At Grokbot, his team calls each guardrail that corrects a model behavior a "shim": every shim is logged each time it is triggered, and a bot proposes deleting it once it is no longer triggered. The same habit suits your own outer harness.

So harnesses are getting thinner where models have learned the job, and they still matter everywhere else. Katz closes his talk on the same note:

"yesterday's harness may be dead, but long live the agent harness of tomorrow." — Jediah Katz (18:01)

This series' article on graph engineering promised to show how the harness became your main lever. That lever is your outer harness, rebuilt with each new model.

With harness engineering, the human sits outside the session, shaping the agent's working environment and its tools.

Coming next in the series: "Loop Engineering, or Sit on the Loop, Not in It", on where the harness ends and the loop begins [article to be published].

Sources