What the paper measured
An agent harness is the software wrapped around a language model that turns the model's output into actions. The harness includes the system prompt, the tool definitions, the loop that runs shell commands and file reads, and the logic that decides what goes back into the context window. Claude Code and OpenAI Codex are both harnesses. On 9 November 2026, researchers from UC Berkeley and the University of Illinois Urbana-Champaign, among them Ion Stoica and Alvin Cheung, posted System Optimizations for Cost-Efficient Agent Harnesses to arXiv. The authors start from earlier findings that a harness has little effect on task accuracy, which depends mostly on the model, while harness choices alone can change the cost of the same model on the same task by up to 2.6 times.
The team's own runs support both halves of that claim. A minimal harness with only a bash tool matched Claude Code and Codex on accuracy for several models. Claude Code and Codex cost about twice as much as the basic harnesses because their system prompts and tool schemas are longer (paper, section 2.3).
Where the tokens go
Section 3 of the paper breaks down agent traces by cost. Cached context reads are the largest item. As a run's context grows, cache reads go from 13 to 30% of total cost to between 53 and 73%. Tool calls weigh as heavily as context size: at similar context lengths, runs with more tool calls cost 1.6 to 26 times more. Much of what tools return goes unused. Agents later draw on about 27% of tool-output tokens, and about 36% of outputs are never used at all.
Filesystem searching is another large cost. On the benchmark traces, searches take about 43% of turns and 28% of cost. On a retrieval benchmark that uses UUID file names in nested folders, searches take 57 to 89% of turns, and about 42% of directory listings repeat a listing from another session.
How Agency works
The authors built Agency, which they call a harness interposition platform. Agency sits between an unmodified harness and the harness's model and environment, and its design borrows from Valgrind, the program instrumentation tool. A sandbox engine launches the harness as a subprocess under ptrace and cgroups, the Linux facilities for tracing system calls and constraining resources. Agency captures each LLM call, process spawn and file access, converts each event into a shared format, logs it to SQLite and passes it through user-written hooks that can rewrite the request before it reaches the backend (paper, section 4.1). Because Agency doesn't modify the harness, one optimisation can be written once and run under both Claude Code and Codex.
To confirm that the interposition layer adds no cost of its own, the team ran Claude Code with Haiku 5.5 on five SWE-bench Verified tasks, 100 times each. Mean per-task cost changed by minus 1.50%, with a 95% confidence interval from minus 4.69% to plus 2.04%, which is consistent with no effect.
The five optimisations
Each technique was tested alone. The cost ratio is cost with the technique divided by baseline cost, so values below 1 are savings (paper, section 4.2; alphaXiv overview):
- Tool-output compaction: shrinks tool outputs by about 14% on average at no extra model cost. Cost ratio 0.95.
- Context garbage collection: a gradient-boosted tree model predicts whether each context block will be read again, and blocks scoring below a 0.3 threshold are dropped. Each compaction removes about 47% of tokens. Cost ratio 0.88.
- Subtask stack machine: compacts the history of finished subtasks every six segments. Each compaction removes about 91% of tokens, but compaction happens only about once every 20 turns. Cost ratio 0.94.
- Metadata-assisted search: keeps file metadata in SQLite tables that the agent can query. On OfficeQA Pro, search calls fall by up to 80%, and the agent reaches target files in 5.6 turns against 8.1. Cost ratio 0.68.
- Tool-call batching: a prompt asks the model to group independent calls. Turns fall by up to 30%, but new input tokens rise 19%, so cost goes up slightly, with a cost ratio of 1.02.
Results across models and tasks
The test set has 100 coding tasks (40 from SWE-bench Verified, 40 from SWE-bench Pro and 20 from Terminal-Bench 2) and 100 OfficeQA Pro retrieval tasks spread across four folder layouts. The models are GPT-6-Luna, GPT-6.1-Sol, Sonnet 5.5 and Opus 5.5. With all five techniques on, the average cost ratio is 0.77, a saving of about 23%. Ratios for individual model and harness pairs range from 0.65 to 0.85, and the "up to 35%" figure in the abstract comes from the best of those pairs (paper, section 5.2).
Savings were largest on document retrieval with opaque file names. OfficeQA Pro ratios run from 0.5 to 0.96. Coding savings were smaller, with SWE-bench Verified at 0.80 to 0.92 and Terminal-Bench 2 at 0.90 to 0.96. In one solved SWE-bench Pro task, total prompt tokens fell from 4.0 million to 2.6 million and peak context fell from 61.3K to 16.3K tokens (alphaXiv overview). The DAIR.AI weekly roundup independently summarises the result as a cost cut of up to 35% with marginal accuracy loss.
Limits and open questions
The abstract describes accuracy as uncompromised, yet the average accuracy ratio is 0.97, which is a small measured drop. By model, the ratios are 0.99 for Opus, 0.97 for Sonnet and 0.98 for Sol, while Luna fell to 0.93 on some OfficeQA tasks. Between 17 and 29% of individual tasks cost more than baseline, so the savings are an average and individual runs vary. Two of the techniques depend on the model following instructions: Luna sometimes added unneeded calls when asked to batch and misused the metadata tables.
The authors also list limits in their own analysis. The cost analysis assumes current provider pricing, and a change in cache-read prices would shift the numbers. The analysis of observed traces is done in hindsight, so the potential savings it reports are an upper bound. The benchmark traces are two to three times shorter than real-world traces, which the authors expect makes their savings an underestimate. The paper doesn't measure wall-clock speed (alphaXiv overview). We found no code repository linked from the arXiv listing, so Agency can't yet be installed as a tool.
What builders can do with it
The breakdown in section 3 works as an audit checklist for any team running coding or document agents on usage-based billing, including teams in Auckland whose agent spend grows with every pull request. Pull a week of traces and work out the share of spend that goes to cached reads against new input, how much tool output the agent later refers to, and how often the agent repeats a directory listing. Teams whose agents search document stores with generated or opaque file names should look at metadata-assisted search first, since that technique gave the largest single saving. Running your own evals against a bare bash-only harness will show how much of your bill comes from system prompt and tool-schema overhead.
Some of the paper's warnings carry over directly. Prompt-level tricks such as batching can increase cost, and cheaper models lose more accuracy when context is pruned, so any change should be measured on your own task mix with both cost and pass rate tracked. If your team runs these measurements, the ASAI projects page is a good place to share the results with other members.
Sources
- System Optimizations for Cost-Efficient Agent Harnesses (arXiv abstract, 2611.12122)
- System Optimizations for Cost-Efficient Agent Harnesses (arXiv full text, HTML)
- alphaXiv overview of arXiv 2611.12122
- DAIR.AI: Top AI Papers of the Week, 15 November 2026
- DAIR.AI Academy: AI Papers of the Week
Build with people working on the same things
Join the Auckland Society for AI: NZ$599 a year with a ForgeBox and the members' projects area. Our Auckland meetups are open to everyone.