HarnessTax on Claude Code, Codex and Pi: cost gaps showed up far more often than success gaps, so measure what your harness re-sends
With the model held fixed, the study detected cost gaps between harnesses far more often than success gaps. In my own Claude Code measurement, the tool-surface overhead cost more in cache writes than in reads, and two short commands show how big it is in your setup.
Contents
A team at UC Berkeley held eight models fixed and swapped the software around them: Claude Code, Codex CLI, and Pi, a harness with four tools and a short prompt. Across 7,092 scored runs on SWE-bench Lite, Terminal-Bench 2.0 and 4.0 and Terminal-Bench Science, its tests found cost differences in most same-model comparisons on the first three benchmarks and success differences in almost none. The paper calls the extra cost of the pricier harness, among pairs whose success rates it can show are close, the harness tax.
I take a measuring habit from it, not a harness switch. HarnessTax and the December 1 Freehand paper both ran Claude Code and Pi with Opus 5.5 on Terminal-Bench 4.0 and on Terminal-Bench Science, and neither shows Pi ahead on success on either benchmark. What the paper does explain well is where a harness’s extra cost sits, and that part you can read off your own setup. On Claude Code 2.1.337 in an empty folder, 15,765 of the 20,261 input tokens of the first request go away when the tools do. On the default model, that block costs about $0.25 every time it is written to the one-hour cache and about a third of a cent every time it is read back, so one write costs as much as eighty reads.
What did the HarnessTax paper find about Claude Code, Codex and Pi?
Cost gaps were common and success gaps were rare. Across SWE-bench Lite, TB2 and TB4, the paired test detected a cost gap in 51 of 72 same-model comparisons (37 after Holm correction) and a success gap in 2 of 72, neither of which survived the correction.
In 36 comparisons the data ruled out a success gap larger than 10 points, tested one comparison at a time (15 of them still after Holm correction). Within those 36, the pricier harness cost a median of 1.33 times as much as the cheaper one, and up to 5.1 times. Pi sits on the cost-success Pareto frontier on every benchmark (six of the eight models ran on TB-Science). Models did not need their provider’s harness: across 21 comparisons, the first-party harness never had a detectable lead over the best alternative, and it cost more than Pi in 17.
The success half needs the caveat the authors give themselves: with 30 to 63 tasks, their test detects a true 10-point success gap only about half the time. A gap they did not detect is not a gap they ruled out.
Does Claude Code really cost twice as much as Pi?
On one model and one release, yes. The 2.1x in the abstract is Claude Fable 5 on Terminal-Bench 4.0 with Claude Code 2.1.224, where Claude Code took 1.3 times Pi’s turns and cost 2.1 times as much, with no detectable success gap.
The Opus 5.5 runs used Claude Code 2.1.280 and came out closer: 1.63 times Pi’s cost on SWE-bench Lite, 1.32 on TB2 and 1.00 on TB4. Its first request on SWE-bench Lite was 25,336 tokens with 19 tools declared, against 32,176 tokens and 23 tools for Opus 4.8 on the older release; Pi’s was 2,553. Model and release changed together, so the paper credits the pair, not the release. The direction is not fixed either: Pi cost more than Claude Code by a detectable margin in four comparisons, Sonnet 4.6 on TB4 among them.
Where does Claude Code’s extra cost come from, according to HarnessTax?
From what the harness re-sends. Every call carries the prefix (instructions, tool definitions, the task), then everything the conversation has kept, and which of the two dominates depends on how long the task runs.
On short tasks it is the prefix. With Fable 5 on SWE-bench Lite, Claude Code made as many calls as Pi, but its calls carried 3.7 times as many input tokens on average, and by the paper’s attribution instructions and tool definitions account for 94% of its extra cost. Its first call on TB4 was about 32K tokens, of which the task was about 600. Eighteen of its 23 tools were never called in any SWE-bench Lite run with that model, and their definitions came to 31% of its cost.
On long tasks it is accumulated context and output: 51% and 25% of Claude Code’s extra cost over Pi with Fable 5 on TB4. A tool output that stays in the conversation is billed again on each later call, so if every call adds roughly the same amount, the cumulative input of an uncompacted thread grows roughly with the square of the number of calls. Most of those re-sent tokens are cache reads, priced at a tenth of the input rate or less, so the share of tokens and the share of cost are different numbers.
Do Claude Code subagents pay for themselves in the HarnessTax results?
The paper cannot say for Claude Code; in Codex, delegation raised cost with no detectable success gain. The cleanest test: giving GPT-5.6 Sol the delegation instructions Codex otherwise adds only at its top effort level raised cost 3.0 times on TB2 at high effort (about three subagents per run), with success at 60.0% against 63.3%, not a detectable difference. A max-effort configuration on TB-Science, with patched subagent defaults and web search left on only in the unmodified arm, raised cost 14.2 times at 60.8 subagents per run. Inside Claude Code the paper only observes: with GPT-5.6 models it started subagents in nearly every TB4 run, against at most 7 runs for any other model, and with Luna on SWE-bench Lite they account for 72% of its extra cost over Pi. The authors say themselves that this whole-harness comparison does not isolate the effect of subagents.
The finding I would carry into practice is about the brief. TB-Science forbids looking up solutions, and with Sol only 24% of Claude Code’s subagent prompts restated that rule; across GPT-5.6 runs, subagents fetched benchmark material in 21 runs and the main agent never did. If you delegate, restate the task’s rules in the subagent’s prompt. I went through which jobs justify a subagent at all in when Claude Code subagents are worth it.
How does HarnessTax square with the Freehand paper’s Claude Code results?
Better than the two abstracts suggest. On December 3 I wrote about Freehand, which found its one-tool harness ahead of Claude Code on Opus 5.5 and behind it on Sonnet 5.5. Both papers ran Claude Code and Pi with Opus 5.5 on the same two benchmarks:
Terminal-Bench 4.0, Claude Opus 5.5
Claude Code
Pi
Third harness
HarnessTax (max effort, 1 run per task)
57.1%, $11.97
57.1%, $12.02
Codex 60.3%, $15.53
Freehand (high effort, 5 rounds)
54.9%, $4.91
57.1%, $5.23
Freehand 61.9%, $3.38
Terminal-Bench Science, Claude Opus 5.5
Claude Code
Pi
Third harness
HarnessTax (max effort, 1 run per task)
64.3%, $23.39
54.3%, $22.67
Codex 60.0%, $26.68
Freehand (high effort, 3 rounds)
54.3%, $12.86
47.1%, $11.02
Freehand 55.2%, $8.16
On Terminal-Bench 4.0 the observed means for Claude Code and Pi are close in both studies, and HarnessTax counts the pair as similar on success at a 1.00x cost ratio. On Terminal-Bench Science both studies have Claude Code 7 to 10 points ahead of Pi at slightly higher cost. HarnessTax does not find its 10-point gap detectable and traces up to 4.3 points of it to Pi’s runs hitting the provider’s request-size cap on large images, which Claude Code avoids by shrinking each image. Freehand tests its own harness against each baseline and has no Claude Code versus Pi test, so its rows are observed means, not verdicts. Both papers price at the same published Opus 5.5 rates; the dollar columns differ because the runs used different numbers and mixes of tokens, under different effort, Claude Code 2.1.280 against 2.1.299 and Pi 0.85.1 against 0.87.1.
The disagreement is about harnesses HarnessTax did not run. Freehand reports its harness 7.0 points ahead of Claude Code on Opus 5.5 (unadjusted p = 0.060) and a net reversal of 13.7 points between Sonnet 5.5 and Opus 5.5, with a 95% interval of 4.1 to 23.5. HarnessTax ran neither Freehand nor Sonnet 5.5, and with one run per task its design would likely not have detected a 7-point gap even if one existed in its data. Read together, the two papers claim less than their abstracts. Swapping among Claude Code, Codex and Pi rarely moves success by an amount these samples can see, and Freehand is a different design that HarnessTax never ran. The gaps that keep showing up are in cost.
How do you measure Claude Code’s first request yourself?
Run one headless call with a one-word task and read the stream it prints: the init event says what loaded, and for a single call the result usage is that call’s input. Start in a fresh empty folder, with your MCP servers and settings files left out, and keep the output outside it:
shell
cd "$(mktemp -d)"claude -p "Reply with the single word: ok" \ --output-format stream-json --verbose \ --strict-mcp-config --setting-sources "" < /dev/null > ~/probe-empty.jsonl
The < /dev/null stops claude -p from waiting for piped input. Then read it with a few lines of Python (saved as probe.py):
python
import json, sysfor line in open(sys.argv[1]): try: event = json.loads(line) except json.JSONDecodeError: continue if event.get("subtype") == "init": print(event["claude_code_version"], event["model"], event["session_id"], len(event["tools"]), "tools,", len(event["mcp_servers"]), "MCP servers") if event.get("type") == "result": u = event["usage"] total = u["input_tokens"] + u["cache_creation_input_tokens"] + u["cache_read_input_tokens"] print(event["num_turns"], "turn(s),", total, "input tokens:", u["cache_read_input_tokens"], "read from cache,", u["cache_creation_input_tokens"], "written")
If it reports more than one turn, the usage is summed over the main agent’s calls, and you need the per-call view in the next section. Run it with python3 ~/probe.py ~/probe-empty.jsonl. Run the probe twice: the split between cache reads and writes depends on what your account already has cached, while the total should move by little (mine moved by 40 tokens between the first and second default run). Then run the same command, without the two flags, from your project folder, with the same model and effort. The change in first-request input is what your project and user configuration (CLAUDE.md files, skills, MCP servers) add on your setup.
On Claude Code 2.1.337, the default model on my account was Fable 5.2, and the init event listed 25 tools. The recorded request showed 11 of them sent with full definitions and the rest deferred behind ToolSearch, the on-demand loading the paper also observed in its Claude Code runs on TB2. What the first request carried:
These do not line up with the paper’s 25K to 33K: different release, model and launch settings. They do show where the weight is. With four tools, the request also lost the agent and skill listings that come with the Agent and Skill tools, so the drop from 20,261 to 7,769 is tool definitions plus those listings, not definitions alone.
/context also works headless (claude -p "/context" with the same flags) and labels its numbers as estimates. For this configuration it estimated 15.1k tokens against the 20,261 the usage fields report, and it listed 15.2k of deferred tool definitions outside its total. Use it to see what the window holds, and the usage fields for what each request carries.
How do you read Claude Code’s per-call input from a session transcript?
From the transcript Claude Code writes for every session it keeps on disk. Find the file by the session id the probe printed and run the script below over it:
Each assistant line in the file carries the usage of the API call behind it. One response can span several lines, so the script keys usage by message id and keeps the last line. Subagents write their own files under <session-id>/subagents/, and it reports each of those as a separate thread (saved as percall.py):
python
import argparse, jsonfrom pathlib import Pathparser = argparse.ArgumentParser()parser.add_argument("transcript", type=Path)main = parser.parse_args().transcript.expanduser()threads = [main] + sorted(main.with_suffix("").glob("subagents/*.jsonl"))for path in threads: usage = {} # message id -> usage; a later line for the same response wins for line in path.open(): try: rec = json.loads(line) except json.JSONDecodeError: continue msg = rec.get("message") or {} if rec.get("type") == "assistant" and msg.get("id") and "usage" in msg: usage[msg["id"]] = msg["usage"] if not usage: continue print(f"== {path.name}") inputs = [] for i, u in enumerate(usage.values(), 1): read = u.get("cache_read_input_tokens", 0) write = u.get("cache_creation_input_tokens", 0) total = u.get("input_tokens", 0) + read + write inputs.append((total, read)) print(f"{i:>4} input {total:>7} read {read:>7} write {write:>6} output {u.get('output_tokens', 0):>5}") summed = sum(t for t, _ in inputs) share = f"{sum(r for _, r in inputs) / summed:.0%}" if summed else "n/a" print(f"calls {len(inputs)} first {inputs[0][0]} last {inputs[-1][0]} " f"summed {summed} cache reads {share}")
I gave the same four-step task to the default tool set and to four tools, from the empty scratch folder (go back to it if you ran the project probe) with permission prompts off, since nobody is there to answer them in a headless run:
shell
TASK='Do these steps one at a time, one tool call per step: 1) run `uname -sr` 2) read the file /etc/os-release 3) run `ls /usr/share/doc | head -40` 4) run `df -h / | tail -1`. Then answer in one line: the OS name and the number of entries step 3 printed.'claude -p "$TASK" --output-format stream-json --verbose --strict-mcp-config \ --setting-sources "" --permission-mode bypassPermissions < /dev/null > ~/task-default.jsonlclaude -p "$TASK" --output-format stream-json --verbose --strict-mcp-config \ --setting-sources "" --permission-mode bypassPermissions \ --tools "Bash,Read,Edit,Write" < /dev/null > ~/task-four-tools.jsonl
Both made five calls and gave the same answer. The script printed, for the default tool set:
The four-tool run went from 7,861 to 8,793 and summed 41,602, with 95% cache reads. Both threads grew by the same 932 tokens, and the default run carried 12,492 more input tokens on each of the five calls, which accounts for the whole 62,460-token difference. That is the paper’s short-task case in miniature: the prefix difference, paid on every call.
Priced at Fable 5.2’s list rates from the caching price table ($8 base input, $0.20 per million for cache reads, $16 for the one-hour writes these runs recorded), those 12,492 tokens cost about $0.0025 per warm call and about $0.20 each time they are written. One write costs as much as eighty warm reads. In the default run the 6,056 written tokens cost about $0.10 and the 97,996 read tokens about $0.02, and that run started on a partly warm cache; a cold start writes the whole prefix. In a run this short, the overhead is paid mostly in writes. A long warm session can read the same block more than eighty times, and then the reads dominate, so compare your own written and read totals.
On one of your own sessions, compare the first and last recorded input of the main thread. The first is close to your prefix plus your opening message. The net change after it is mostly accumulated context, plus any later messages and loaded definitions, minus whatever compaction or cleared tool results removed. The transcript does not show which tokens are which; it shows how fast the thread grows.
Which Claude Code settings cut the harness tax, and which do not?
The ones I measured cut the prefix: --tools restricts the built-in set, and --disallowedTools removes single tools. I tested both only in headless runs, and only for token counts, not for whether tasks still succeed with fewer tools. A tool that is already deferred, like the cron and worktree tools on 2.1.337, starts as a name in the deferred list and loads its schema only when used; a tool sent in full carries its whole definition on every call. The empty-folder probe left out MCP servers and instruction files, and the project-folder run shows how much they add on your setup; the paper’s point about definitions you never call applies to them as much as to built-in tools.
The paper’s component studies are almost all on Codex, at high effort with GPT-5.6 Sol and Luna on TB2, so read them as evidence about design choices, not about Claude Code’s switches. Capping each tool output at 2,000 tokens cut cost by 26% with Luna and 14% with Sol, with no detectable change in success. Replacing Codex’s tool set and its code-mode calling with four directly called tools lowered mean cost in 10 of 12 comparisons, four of them detectably and one after Holm correction; the authors credit the tool set and the direct calls together. Trimming tool descriptions removed 492 tokens from the first call and changed neither cost nor success detectably.
One study ran on Claude Code itself: Opus 5.5 at max effort on 2.1.280, 15 TB4 tasks, compaction moved from about 167K tokens to 100.8K or 64.8K. At 64.8K, success fell 24.4 points, a drop that survived Holm correction, mean cost was 1.47 times the default’s (not detectable), and runs took 1.56 times as long. Claude Code’s guard against repeated compaction ended 15 of the 45 runs there, counted as failures; without them success was still 13 points lower. At 100.8K, cost rose 1.70 times (detectable before correction, not after) and success fell 13.3 points, not detectably. With the 1M window no run reached its threshold, and cost and success did not change detectably. Ten of the 15 tasks were picked from runs that had compacted, so this is a test on compaction-heavy work. On that work, compacting at 64.8K, the intuitive way to trim context, was the one change that measurably hurt success.
Does Claude Code’s harness tax matter on a flat Claude plan?
In context, yes; in plan usage, these numbers cannot say. Some of the paper’s runs used subscription logins, but every run was priced at fixed API rates, and the study did not measure what a plan’s allowance consumes. Anthropic does not publish how tokens convert to plan usage, so neither my probes nor the paper establish how much of an allowance the prefix uses. The prefix occupies the window on every request whatever you pay: 20K tokens is 2% of a 1M window, and your MCP servers and instruction files add to it. The authors also name the gap that matters most for daily use. They did not measure real interactive sessions, “where interactive features may justify their cost.”
What should you change after reading HarnessTax?
For me, not the harness. On Opus 5.5 neither paper shows Pi ahead of Claude Code on success on either shared benchmark, and on Terminal-Bench 4.0 both found them at roughly the same cost. Other model and benchmark pairs had cost ratios up to 5.1x, so the trade-off is worth checking on your own workload. What I would change is what I look at. Two commands show your first request and how a session grows on top of it, and on Fable 5.2 a write of that block costs as much as eighty reads, so how often it gets rewritten matters as much as how big it is. Tools you never call are where I would start cutting, and each cut is a hypothesis: measure the tokens, then check that your tasks still pass.
01 / Discussion
No comment section here — all discussions happen on X.