Harness engineering

Hand-drawn flat terracotta straps with two rings and three rectangular buckles wrap a central oval of flowing moss, sand and umber lines, over wavy umber, sand and moss hatching.

An agent harness is the software around a language model that turns it into an agent. It runs a loop of model and tool calls, chooses what the model sees, keeps state, and controls which actions may run (Barbaste et al., 2026). Harness engineering is the work of designing and revising that software (Barbaste et al., 2026); it differs from building an evaluation harness, which runs and scores benchmarks. With the model held fixed, a different harness can change which tasks get solved and what they cost, by amounts that depend on model, tasks and budget (Zhang et al., 2026x; Liu & Han, 2026). Studies disagree on whether harness or model matters more, on whether automatically designed harnesses beat simpler uses of the same compute, and on how much harness stronger models still need.

Where the terms came from

Earlier sources used other names for the same software, such as a scaffold. A January 2024 report on evaluating agents used scaffolding program for software that lets a model act and observe the results in successive steps (Kinniment et al., 2024). In July 2025, LangChain described context engineering as deciding what information the model has at each step (The LangChain Team, 2025).

Uses of harness for this software appear in early 2026. In January, Schmid used agent harness for the infrastructure that wraps a model to manage long-running tasks (Schmid, 2026c). On 5 February, Hashimoto used harness engineering for changing an agent’s tools or instructions after it made a mistake (Hashimoto, 2026). On 17 February, Trivedy used the term more broadly, for designing the system prompt, tools and execution flow around a model, with context delivery as one of its jobs (Trivedy, 2026).

A later source-code study adopted the broad sense, and scaffold still overlaps with it. That study defines harness engineering as designing and evolving the model’s surrounding runtime (Barbaste et al., 2026). A survey keeps both words: a harness is a configured execution runtime, and a scaffold is the overlapping layer of prompts and workflow structure (Meng et al., 2026).

What a harness does Weak evidence: few or small studies support this

Studies that inventory harnesses name overlapping parts, among them a control loop, tools, context and state, and controls on execution. One study traces these through the source code of eleven coding agents (Barbaste et al., 2026). Another codes thirteen agents at fixed versions, and a survey rates 34 systems against six runtime functions: execution, tools, context, persistent state, lifecycle hooks and evaluation (Rombaut, 2026; Meng et al., 2026). How an agent’s tools are described and shaped is a subject of its own, covered in Tools for AI agents.

The studies draw the boundaries between these jobs differently. One treats the link to the model provider (protocols, prompt construction, choice of model) as a subsystem of its own, and treats transcripts, persistence and resuming a session as cross-cutting (Barbaste et al., 2026). The survey instead gives persistent state and evaluation their own functions (Meng et al., 2026). A third proposal lists eleven responsibilities, including task specification, failure attribution, checking and recording human interventions (Zhong & Zhu, 2026).

Not every harness has every part. The eleven-system study allows a subsystem such as orchestration to be absent by design (Barbaste et al., 2026). The minimal mini-SWE-agent, by its documentation, keeps an append-only message history with no separate step that reshapes it (SWE-agent team, n.d.a). Where a part lives can depend on the integration. In Cloudflare’s agent platform, Pi and OpenCode keep their own transcripts, while Claude Code and Codex use a shared SQLite-backed store (Cloudflare, 2026a).

How much the harness changes results Contested: studies disagree on this

Studies disagree on how much the harness matters next to the model. Some controlled comparisons find large harness effects, and one finds them larger than the effect of switching models. On 100 SWE-bench Verified coding tasks, a full harness beat a minimal one by 8.5 to 13.0 percentage points of first-try success. Models in the same harness differed by 2.5 to 5.0 points (Zhang et al., 2026x). When the context window was tight, a bundle of harness changes raised complete solutions from 43 to 72 of 169 tasks (Lewis, 2026).

Other studies find the harness effect small, or no larger than chance. On SWE-Bench Pro V2, scaffold choice explained 0.29% of the variation in whether a task was solved, against 2.65% for model choice (Dan et al., 2026). These are shares of the variance in whether tasks were solved or failed. On 45 difficult tasks, swapping the harness changed 13% of outcomes at the median, as many as rerunning an unchanged configuration (Liu & Han, 2026).

StudyModel and tasksWhat changedOutcome
Zhang et al. (2026x)Three models; 100 SWE-bench Verified tasksMinimal to full harness+8.5 to +13.0 points; 2.5 to 5.0 points between models
Lewis (2026)Qwen3.6; 169 SWE-bench Verified tasks, 20,480-token windowBundle of harness changesMean share of failing tests fixed 28% to 49%; complete solutions 43 to 72
Liu and Han (2026)Qwen3.8-27B; larger SWE-bench Verified poolOpenCode, Claude Code, mini-SWE-agent70.1%, 78.2%, 79.3%
Liu and Han (2026)45 difficult SWE-bench Verified tasksHarness swap versus unchanged rerun13% of outcomes changed at the median in both
Dan et al. (2026)642 SWE-Bench Pro V2 tasksModel and scaffold2.65% of outcome variance for model, 0.29% for scaffold
Bjarnason et al. (2026)Devstral-2, temperature 0; SWE-bench Verified, ten runs eachnano-agent versus r2e-gym63.8% versus 35.4%, ranges not overlapping
Li et al. (2026g)GPT-6 Astra; 63 Terminal-Bench 4 tasksPI versus DeepSeek Harness60.32% at $4.66 per task versus 52.38% at $19.94

Run-to-run noise is large enough to hide small harness effects, but some gaps exceed it. Repeating each configuration ten times on SWE-bench Verified gave pass rates that spread by 2.2 to 6.0 points within a single setting. In the same study, one model scored 63.8% in one harness and 35.4% in another, with no overlap between their runs (Bjarnason et al., 2026).

Harness choice can also change cost sharply. With model and tasks fixed, the dearest harness cost under 10% more than the cheapest for some models, and 3 to 4 times as much for another (Liu & Han, 2026). In another comparison, a lean harness scored higher than a heavier one at less than a quarter of the cost per task (Li et al., 2026g).

Effects of individual parts

Experiments that change one part of a harness at a time find effects that depend on the model, the budget and the tasks.

Planning and tool design Weak evidence: few or small studies support this

A planning step can help a smaller model. Asking Nemotron-3 30B to plan before acting raised its success on SWE-bench Verified by 11.6 percentage points, with a 128,000-token context budget (Fan et al., 2026c). Passing evidence from one iteration to the next also mattered in a multi-iteration agent: removing it lowered a game-building score from 71.52 to 65.23 (Yan et al., 2026b).

A gain from purpose-built tools was not found in a later study. In 2024, SWE-agent’s tailored agent-computer interface beat a plain Linux shell by 10.7 points on SWE-bench Lite (Yang et al., 2024e). A 2026 study crossing two agents with two benchmarks detected no significant difference in success between tool designs. On SWE-bench, restricting the agent to a single code-execution tool cut cost for Codex, while Claude’s cost moved, not significantly, the other way (Yang et al., 2026i). With only shell tools, the large Nemotron-3 550B succeeded more often and at lower cost (Fan et al., 2026c).

Tests, checks and repository files

Practitioner guides make mechanical checks part of the harness, but they describe practice rather than measure it. In a vendor case report, OpenAI’s application team enforced the architecture’s allowed dependency directions with custom linters and structural tests (Lopopolo, 2026). Adobe’s guide recommends one make check command that runs linting, type checking and tests (Adobe, n.d.a).

Test feedback helps or hurts depending on the quality of the tests. With the repair agent held fixed, tests written by one model lowered its success from 61.2% to 57.3%, and tests written by another raised it to 65.3% (Tao et al., 2026). Prompting agents to write more or fewer tests of their own left the number of solved tasks statistically unchanged, though resource use changed for three of four models (Chen et al., 2026q). Under matched settings, one feedback controller raised the mean pass rate from 61.2% to 68.2% while lowering cost (Zhang et al., 2026r).

Passing the functional tests does not mean a change meets the project’s other rules. SWE-Gate turns constraints from pull-request review comments into separate tests. Of 644 patches that passed the functional tests, 221 failed the constraint tests, although the constraints had been given to the agent (He et al., 2026d).

Repository instruction files for agents add cost without a general gain in success. Across several coding agents and models, files in the style of AGENTS.md did not generally raise task success. They raised inference cost by over 20% on average, even though agents followed them (Gloaguen et al., 2026). How such files are loaded and worded is covered in Agent skills and Progressive disclosure for AI agents.

Context and state across sessions

Harnesses can carry state outside the conversation so that a task survives a fresh session. In a vendor case report, Anthropic had each fresh coding session read a progress file and the Git history to learn where earlier sessions had left the work (Young, 2025).

Managing context helps less as the context budget grows. In matched ablations, the accuracy benefit of context management shrank as budgets widened (Fan et al., 2026c). In a comparison of whole harnesses on long mixed sessions, Opus 5.5 managing its own context matched Claude Code’s task success. It cost 34% less than Claude Code’s explicit 200,000-token setting and 49% less than its default (Busch et al., 2026).

Compaction Weak evidence: few or small studies support this

Compaction, in which the harness condenses earlier conversation once the context fills up, is rare in benchmarks, yet in sampled real use the sessions that compact use many tokens. More than ten frontier coding benchmarks rarely triggered even one compaction with current models. In sampled GitHub Copilot agent sessions, 7.8% compacted, and those sessions accounted for 44.2% of all tokens (Liu et al., 2026e). That share describes the compacting sessions as a whole, not the tokens compaction itself used.

Permissions and sandboxing Weak evidence: few or small studies support this

Evidence on permissions comes mostly from vendor reports, and it measures interruptions rather than safety. Anthropic reported 84% fewer permission prompts after it gave Claude Code an operating-system sandbox, with writes limited to the workspace and network access denied by default (McGuinness et al., 2026). OpenAI’s Codex sends requests that would cross its sandbox boundary to a separate approval agent (Trębacz et al., 2026).

Asking a person to approve each action does not guarantee close review. In a developer survey, 61% (64 of 105) of those who carefully reviewed most or all agent-written code often approved some kind of action without close review (Wu et al., 2026d).

What simplifies as models improve Weak evidence: few or small studies support this

In some comparisons with strong models, minimal harnesses matched elaborate ones. Under matched time budgets, a minimal single-session agent matched or beat four specialised machine-learning engineering harnesses with the frontier models tested (Brilliantov et al., 2026). On 80 private coding tasks, neither of two vendor-native harnesses showed an average advantage over a neutral harness running the same model (Arjmandi, 2026). In a vendor case report, Anthropic’s builder on Opus 4.6 ran coherently for over two hours after it dropped the sprint decomposition used with Opus 4.5 (Rajasekaran, 2026).

The best harness still depends on the model and the task. In a study crossing five models with several harnesses, the top-scoring harness changed between benchmarks for four of the five (Li et al., 2026g). Opus 4.8’s vendor harness showed opposite differences on repository tasks and contest tasks, a pattern found after the fact (Arjmandi, 2026).

Harnesses grow and drift, and growth does not guarantee gains. Five major open-source coding harnesses together shipped more than two releases a day. Across 35 releases of Qwen Code run with one fixed model, later versions used nearly twice the tokens and tool calls without a significant gain in solved tasks (Ben Sghaier et al., 2026). In a six-week case study of one repository, stale documentation was involved in 48 of 118 agent failures. On a newer model, three of four completed replays did not repeat their failure even without the old fix, but one failure recurred once its check was removed (Hassanzadeh Aliabadi, 2026).

Reporting harnesses in benchmarks

Because the harness moves scores, one proposal asks benchmark reports to include a Harness Card describing the configuration in seven categories. It comes with a breakdown of variance and measures taken from the agent’s step-by-step record (Zhang et al., 2026x).

In one small audit, benchmark papers disclosed their harnesses only in part. Seven of eight agent benchmark papers described their scaffold and tools to some degree but did not pin the exact environment image. The eighth scored zero on harness disclosure, in this pilot scored by one rater (Naser Moghadasi & Ghaderi, 2026). The software that runs those benchmarks is covered in Evaluation tooling for AI agents.

Automatic harness design Contested: studies disagree on this

Studies disagree on whether harnesses designed by a search process are worth their cost: two searches beat hand-built harnesses, but a third study found no advantage over simpler ways of spending comparable compute. Two search methods reported gains on Terminal-Bench 2. One raised pass rate from 69.7% for its starting harness to 77.0% after ten rounds of evolution, against 71.9% for the hand-designed Codex harness (Lin et al., 2026b). Another, with Opus 4.6 held fixed, reached 76.4% against 74.7% for the hand-engineered Terminus-KIRA (Lee et al., 2026b).

Another study found no advantage. On Terminal-Bench 2.1, harness evolution did not beat simple test-time scaling, which spends extra compute while the agent runs, with or without test feedback. The evolved harnesses also generalised only to a limited degree (Wang et al., 2026r). Agents that revise their own instructions, memory and tools more broadly are covered in Agent self-improvement.

Further reading

  • Barbaste et al. (2026): a source-code study of eleven coding agents that names the parts of a harness and defines harness engineering.
  • Zhang et al. (2026x): a matched model-by-harness experiment and the Harness Card proposal for disclosing harnesses in benchmarks.
  • Liu and Han (2026): compares harness swaps with unchanged reruns, and the cost of the same work across harnesses.
  • Fan et al. (2026c): ablations of planning, context management and tool sets in coding agents.
  • Wang et al. (2026r): a test of whether automatically evolved harnesses beat simpler uses of the same compute.
  • Young (2025): a vendor account of carrying state across sessions in long-running coding work.

Known gaps

What this article cannot tell you yet.

  1. Harnesses for agents outside software engineering were not researched; almost every comparison in this article uses coding benchmarks.
  2. The human time and money spent maintaining a harness across repository and model changes has not been estimated.
  3. The effect of enforced review gates on defects that reach production was not measured; the evidence counts what separate tests detect.
  4. The safety outcomes of permission systems and sandboxes rest mostly on vendor evaluations; independent comparisons measure prompts and reported attention.
  5. The separate effects of adding sub-agents, or of memory kept across unrelated sessions, were not isolated in the comparisons gathered.
  6. Most results come from 2026 preprints, and exact independent replications of particular harness gains are few.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 43 references