Notes ·

The fix that cost tokens

TraceRazor measured its own patch on 12 live coding runs and found it raised token use by 5.6 percent instead of cutting it. What the rerun gate caught, what changed, and why a second round centred on zero was the right answer.

TraceRazor audits an agent trace, names the waste it finds, and proposes fixes. Early on I decided that a proposed fix is only an estimate until the same task is rerun with the same model and the token count is measured. That rule is what caught my own patch.

The setup

Six small Python repair tasks, each run twice, gave 12 before-and-after pairs. One model (Claude Haiku 4.5), one agent harness, pytest as the oracle: a run passes only if the failing tests end green. Token counts come from the provider, not from character estimates, and the aggregate uses a seeded 10,000-resample bootstrap for 95 percent confidence intervals.

The 12 stock runs scored a TAS of 80.7 to 85.7 (mean 83.5, on the v0.4 scorer the study ran on). Every audit emitted exactly one auto-applicable safe fix, goal_anchor, triggered by trajectory path entropy, with an estimated saving of 0.5k to 2.4k tokens per run.

Round one: the patch made things worse

Measure Result
Mean token reduction minus 5.6 percent, so 5.6 percent more tokens (95 percent CI minus 11.4 to plus 0.2)
Mean TAS delta minus 1.5 (95 percent CI minus 2.7 to minus 0.4)
Pass rate 12 of 12 before, 12 of 12 after
Estimate accuracy minus 102 percent (95 percent CI minus 205 to 0)

A negative reduction is a cost. Per pair, the reductions ran from minus 23.4 percent to plus 13.0 percent. The audit had predicted a saving; the measurement found a mean cost, with an interval that only just reaches zero. The firmer result is the score: TAS fell by 1.5 points, and that interval excludes zero.

The mechanism was in the patch text. The old anchor told the agent to "restate the stated task objective in one sentence before each reasoning step." These agents were already on track: the goal-advancement check passed on all 12 before-traces, so there was no drift to recover. The anchor saved nothing and charged a restating ritual on every turn.

The change

The remediation text changed and nothing else did. The new anchor keeps the objective as working context, tells the agent to skip actions that do not advance it, and says "do not restate the objective or summarise progress unless explicitly asked." The detection logic and the conservative 25 percent recovery estimate stayed as they were.

Round two: zero, which is correct

Same 12 before-traces, same protocol, fresh audits, 12 fresh after-runs.

Measure Result
Mean token reduction plus 0.7 percent, so 0.7 percent fewer tokens (95 percent CI minus 8.9 to plus 9.9)
Mean TAS delta 0.0 (95 percent CI minus 1.2 to plus 1.2)
Pass rate 12 of 12 before, 12 of 12 after

The standing cost is gone, and the interval is centred on zero. That is the right value for this workload. A drift remediation applied to agents that are not drifting should do nothing, and now it does nothing. Whether the anchor saves tokens on agents that genuinely drift is the next experiment, and it needs a workload where the goal-advancement check actually fails.

What I keep from this

  1. A projection is not a saving. The tool reports both, labels them differently, and the bench command exists so that nobody, me included, can quote the estimate as the result.
  2. Single pairs prove nothing. Across the pairs, the token deltas spanned minus 30 to plus 24 percent. The aggregate interval is the unit of claim.
  3. Read the limits before the headline. Six tasks, one model, one domain. Expected-failure test runs read as tool misfires, and the semantic-drift prior misreads read, edit, test sequences as drift. Detection on coding traces is biased towards firing, so any remediation has to be cost-safe even when it fires for the wrong reason. Round one is what enforcing that looks like.

The full tables, the harness and the reproduction commands are in docs/case_study.md in the repository.