Should AI Agents Use the Same Harness for Every Task?

Every mechanism in an agent harness helps some tasks and gets in the way of others. Choosing the mechanisms task by task, and often choosing none, scored higher overall than any fixed setup we tested.

By Peng Kuang, Haohan Wang, and others · · About our arXiv preprint

Key findings

  • In the STITCH paper (Peng Kuang, Haohan Wang, and others, arXiv 2026), choosing harness parts per task raised GPT-5.6-Luna from 60.0% to 72.2% Pass@1 on 45 Terminal-Bench 2 tasks and from 73.0% to 80.5% on 100 SWE-bench Verified tasks, compared with the fixed Mini-SWE-agent harness it starts from.
  • STITCH left the starting harness unchanged on 51 of 100 SWE-bench Verified tasks and 23 of 45 Terminal-Bench 2 tasks, and added exactly one part on most of the others (arXiv 2609.38912).
  • Leaving one part on for every task was not reliably better: on SWE-bench Verified, three of the six parts tested scored below the plain harness (71.5% to 72.5% against 73.0%), and adding parts at random scored 73.3% (arXiv 2609.38912).
  • Choosing the parts cost 2.7% of one agent attempt on Terminal-Bench 2 and 4.3% on SWE-bench Verified, which the STITCH paper estimates is 638 and 543 times cheaper than a lower bound for writing the harness code from scratch.

Should an AI agent run the same harness for every task?

Most AI agents use the same harness for every task: one fixed set of prompts, tools, checks and retries around the model, whether the job is a one-line bug fix or recovering a damaged database. Our results suggest they should not. With the model held fixed, choosing harness parts for each task reached 72.2% on Terminal-Bench 2, against 60.0% for the fixed harness it was built on and 66.7% for the best single part added everywhere.

The reason is simple to state. A check that replays the tests before finishing is useful when there is a test to replay. On a task without one, it is extra context and extra steps. A fixed harness has to decide once, for all tasks, whether to carry that check. Either way it loses something: the benefit on tasks that need it, or the overhead on tasks that do not.

Our paper, Composing Task-specific Agent Harnesses at Test Time with Reusable Primitives, by Peng Kuang, Haibo Jin, Dehao Wu, Xiaopeng Yuan, Jerry Wang and Haohan Wang at the University of Illinois Urbana-Champaign and Feiyang Deng at the University of Michigan, Ann Arbor, makes this precise and then builds a system around it. The analysis uses a simplified model in which each mechanism helps inside its scope and costs something outside it. Under that model, the best fixed harness is always strictly worse than an ideal per-task choice, and a selector does not have to be perfect to beat it. Its mistakes only have to cost less than the mismatch does.

Key terms

Agent harness
The program around a language model that builds its context, runs its actions through tools, checks results and decides when to stop; Codex CLI and Mini-SWE-agent are harnesses.
Task-specific harness
A harness assembled for one task from that task's instruction and environment, instead of one shared by all tasks.
Harness Primitive
A reusable, already implemented harness mechanism that carries an application scope (when it should help) and a composition contract (its inputs, outputs, setup and dependencies).
STITCH
The framework in our paper: an LLM composer selects Harness Primitives for a task, and a deterministic compiler connects them into a runnable harness.
Seed harness
The plain starting harness, here Mini-SWE-agent 2.4.6, which STITCH extends or leaves alone.

How do you build a task-specific agent harness without writing new code?

The obvious way to get a harness per task is to have a model write one. The paper points out a risk: if each generated mechanism can fail on its own, the chance that the whole harness runs falls exponentially with the number of mechanisms. Generation and debugging also cost tokens.

STITCH separates the two jobs. Before test time, a development agent runs the seed harness on development tasks, reads the failures, looks for deficiencies that recur, and implements a mechanism for each. A mechanism is kept only if its own tests pass and it has a positive effect on success in matched runs with and without it. At test time, the composer, which uses the same model as the agent, reads the task and the scope of each part and names the parts to use. The compiler, which involves no model, supplies the dependencies, connects everything and checks that the result is valid. If it is not, the composer gets a bounded number of corrections, and then the seed harness is used.

Diagram of STITCH. Before test time, failed runs of the seed harness are grouped into recurring gaps, each gap becomes an implemented and tested Harness Primitive, and the primitives form a library with a scope and contract for each. At test time, an LLM composer reads one task and names the parts whose scope fits, a compiler without an LLM connects and checks them, and the agent runs the resulting task harness. Example decisions: State Guard when source files must not be damaged, Execution Supervisor when a background service must stay up, or keeping the seed harness when nothing fits.
The library is built once from failures. For each task the model only chooses; a deterministic compiler does the wiring.

One primitive, State Guard, shows what these parts look like. In development runs, agents kept destroying files they needed later. In one database recovery task, the agent opened the original database before saving its write-ahead log, and opening it removed the evidence needed for recovery. State Guard saves a copy and a hash of the designated files before the first action, restores them if an action changes them, and tells the agent that the action failed. It does not solve the task. It is also the wrong choice when the task is to edit those very files, and its scope says so.

Does adding more to an agent harness make the agent better?

Not reliably. The authors took each primitive and left it on for every task, together with the dependencies it needs. On Terminal-Bench 2 this usually helped. On SWE-bench Verified it mostly did not: three of six scored below the seed harness, one equaled it, and two scored above it. A composer that picked parts at random scored 73.3%, close to the seed's 73.0%. With the same library, picking by task scored 80.5%.

Two dot plots of Pass@1 with GPT-5.6-Luna. On SWE-bench Verified the seed harness scores 73.0; primitives always on score 76.0 for Environment-capability Runner, 73.5 for Change-surface Tracer, 73.0 for Domain-trace Template, 72.5 for Contract-case Explorer, 72.0 for Compatibility-envelope Gate and 71.5 for Discriminating-oracle Runner; STITCH scores 80.5. On Terminal-Bench 2 the seed scores 60.0; State Guard 66.7, Check Replay 65.6, Execution Supervisor 65.6, First-Failure Localizer 62.2, Experiment Keeper 58.9; STITCH 72.2.
The same parts that add little when always on add much more when they are used only where they fit.

The best part also depends on the kind of task. Among the always-on parts, Contract-case Explorer did best on SymPy and Environment-capability Runner on Django. In Terminal-Bench 2, State Guard led on medium tasks and Execution Supervisor on hard ones.

The choice STITCH made most often was to add nothing. Its instructions tell the composer to apply each part's criteria literally and fall back to the seed harness when none fully qualifies, and that happened on about half of the tasks in both benchmarks.

Counts of tasks by number of primitives the composer selected. SWE-bench Verified, 100 tasks: none on 51, one on 39, two on 7, three on 1, four on 2. Terminal-Bench 2, 45 tasks: none on 23, one on 22.
Selection is sparse. Only 10 of the 145 tasks received more than one part, all of them in SWE-bench Verified.

How much does a task-specific harness help, compared with Codex CLI and others?

All rows below use GPT-5.6-Luna at medium reasoning effort, with two attempts per task. Pass@1 is the share of successful attempts; Pass² is the share of tasks solved in both attempts, a measure of consistency.

HarnessSWE-bench Verified Pass@1SWE-bench Verified Pass²Terminal-Bench 2 Pass@1Terminal-Bench 2 Pass²
Mini-SWE-agent (seed harness)73.0%68.0%60.0%51.1%
Codex CLI79.0%75.0%56.7%46.7%
MetaHarness (optimized, fixed)73.5%68.0%55.6%44.4%
MemoHarness (adapts text per task)70.5%64.0%53.3%40.0%
Best single primitive, always on76.0%73.0%66.7%57.8%
Random choice of primitives73.3%68.6%63.5%55.2%
STITCH (chosen per task)80.5%76.0%72.2%66.7%

The parts carried over to models that were not used to build them, with their scopes adjusted on development tasks and their code unchanged. Averaged over GPT-5.6-Terra, DeepSeek-V4-Flash and Claude-4.5-Haiku on SWE-bench Verified, the seed harness scored 75.2%, Codex CLI 78.5% and STITCH 84.0%. They also carried over between kinds of work: a library built only on SWE-bench tasks took Terminal-Bench 2 from 60.0% to 71.1%, close to the 72.2% of the library built for it.

The overhead of choosing is small, 4.3% of the token cost of one attempt on SWE-bench Verified and 2.7% on Terminal-Bench 2. For comparison, the paper estimates what it would take an ideal coding agent to simply emit the full harness code, with no reasoning or debugging: 23.35 and 17.23 attempts' worth.

What do other studies say about fixed and task-specific harnesses?

Whether a harness helps appears to depend on the model and the task in several independent studies. How to act on that is where the approaches differ.

  • Beyond the Model: Demystifying Harness Effects in Software Engineering Agents (Haichuan Hu, Quanjun Zhang and colleagues, arXiv 2026) tests harness components across ten open-weight models. Structured tools and task-specific subagents gave the most stable improvements, while context compression and general subagents could hurt repository generation. Our always-on results point the same way with a different set of parts.
  • Harness or Model? Isolating the Harness Effect in Agentic Coding (Mohsen Arjmandi, arXiv 2026) finds no average advantage for either of two harnesses on Claude Opus 4.8, and the average hides a split: the native harness trails by 9.0 points on repository tasks and leads by 23.7 on contest tasks. The author notes that the split was chosen after seeing the data and needs replication.
  • How good is your harness? (Jiwoo Han and Yuekai Sun, ICML 2026 workshop) separates model and harness effects statistically on Terminal-Bench 2.0. Picking the best harness helps about as much as picking the best model, and some harnesses suit some models better than others.
  • JIT-Agent (Guibin Zhang and colleagues, arXiv 2026) trains a model to write and repair a harness for each task. This is more flexible than choosing from a library, since it can invent mechanisms no library holds, and it reports gains of up to 20.2 points for GLM-5.2. We analyze the cost and reliability of generation in general; we did not run JIT-Agent, so this post cannot say which works better.
  • Meta-Harness (Yoonho Lee and colleagues, arXiv 2026) searches over harness code and keeps one improved harness, and MemoHarness (Yue Huang and colleagues, arXiv 2026) adapts a learned harness to each case using retrieved experience. Both report gains over their baselines in their own papers. Under our setup, with one seed harness and development tasks kept separate from the test tasks, neither beat the seed on Terminal-Bench 2. The models, baselines and task splits differ, so the two sets of results are not a direct contradiction.
  • Rethinking the Evaluation of Harness Evolution for Agents (Yike Wang and colleagues, arXiv 2026) is the caution to keep in mind. On Terminal-Bench 2.1, automatically evolved harnesses did not beat simple test-time scaling at a matched budget, and gains mostly vanished on held-out tasks. Our evaluation uses held-out tasks. It does not include a baseline that spends the same budget on extra attempts.

What this does not show

This is an arXiv preprint and has not been peer reviewed, and the samples are small: 100 SWE-bench Verified tasks and 45 Terminal-Bench 2 tasks, two attempts each, with no confidence intervals reported. The 12.2-point gain on Terminal-Bench 2 is 11 attempts out of 90. The 1.5-point lead over Codex CLI on SWE-bench Verified is 3 attempts out of 200, too few to separate the two.

STITCH does not lead everywhere. Codex CLI scored higher on the SWE-bench repositories other than Django and SymPy (85.3% against 83.8%) and with GPT-5.6-Terra (88.0% against 86.5%). On the hard Terminal-Bench 2 tasks, Execution Supervisor left always on matched STITCH at 46.2% Pass@1 and solved more tasks in at least one of two attempts.

The 638-times figure compares selection with an estimated lower bound for writing a complete harness, not with a generation system that was run. It also leaves out the one-time cost of building the library. The theory ignores interactions between parts and assumes that compiled harnesses run, and it does not show that composition beats code generation with repair. Both benchmarks are coding and terminal work, so other kinds of agents remain untested.

Frequently asked questions

Should AI agents use the same harness for every task?

Not if the tasks differ much from one another, according to the STITCH paper (arXiv 2609.38912). With GPT-5.6-Luna held fixed, choosing harness parts per task reached 72.2% Pass@1 on 45 Terminal-Bench 2 tasks, against 60.0% for the fixed Mini-SWE-agent harness and 66.7% for the best single part left on for every task. On about half of the tasks, STITCH chose to keep the plain harness.

Does adding more to an agent harness make the agent better?

Not reliably. In the STITCH paper, three of six harness parts scored below the plain harness on SWE-bench Verified when left on for every task (71.5% to 72.5% against 73.0%), one matched it, and two scored above it. On Terminal-Bench 2, four of five scored above it and one below.

Can an LLM write its own harness for each task?

Yes, and systems such as JIT-Agent (arXiv 2608.25593) train a model to do so and to repair the harness when it fails. STITCH takes another route: the LLM only names existing, tested parts, and a deterministic compiler connects them. That selection cost 2.7% of one agent attempt on Terminal-Bench 2 and 4.3% on SWE-bench Verified.

Does the harness matter more than the model?

Both matter, and they interact. A statistical analysis of Terminal-Bench 2.0 by Jiwoo Han and Yuekai Sun (ICML 2026 workshop) found gains from picking the best harness comparable to gains from picking the best model. In the STITCH paper, changing only how the harness was chosen moved GPT-5.6-Luna by 12.2 points on Terminal-Bench 2 and 7.5 points on SWE-bench Verified.

Citation

@article{kuang2026stitch,
  title     = { Composing Task-specific Agent Harnesses at Test Time with Reusable Primitives },
  author    = { Kuang, Peng and Jin, Haibo and Wu, Dehao and Deng, Feiyang and Yuan, Xiaopeng and Wang, Jerry and Wang, Haohan },
  journal   = { arXiv preprint arXiv:2609.38912 },
  year      = { 2026 }
}

Related from our lab