Fewer tokens to shipmaclulich.com

How to tell whether your coding agents are saving you work

INVOICE HISTORYBriefBuilderTestsReviewerDeliveredMERGEReturn belt
INVOICE HISTORYBriefBuilderTestsReviewerDeliveredMERGEReturn belt
0:21 / 0:21

One task, two coding attempts, one accepted change.

Five things to change before you trust your agent numbers

  1. Count every attempt, not just the one that landedA cheaper attempt that needs a retry can cost more per accepted change
  2. Catch copies by their code, not their nameA name warning was wrong 34 times in 39 and never fired on a renamed copy. A cross-file checker caught 2 of 3
  3. Test your reviewer on changes you know are correctMine caught 12 of 12 broken changes, and blocked 4 of 12 correct ones
  4. Count each fix once, not once per fileCounting per file turned 21 fix commits into 29
  5. Tell an agent working alone how to decideAll four of my first redesign runs stopped to ask someone who wasn’t there
From five small studies of my own agents. None of them measured token or time savings on real work.

Count every attempt, not just the one that landed

If you run AI coding agents, you’ll want to know whether they save you work. The five changes above came from testing that on my own setup.

My agents run under Rigby, a supervisor I built that briefs each task, has the change reviewed and merges it once accepted. Fewer tokens to ship, the series this closes, follows one such change.

The tempting number is tokens per attempt. But a cheaper attempt that needs more retries can still cost more per change, so I count everything it took to land.

What to count for each accepted change

  1. Every attemptFailed and abandoned attempts stay in the total
  2. The brief and the reviewThey use tokens too, so they’re in the batch
  3. Tokens by kindUncached input, cache writes, cache reads and output, kept separate. Reasoning sits within output, never counted twice
  4. Spend and timeActual spend and elapsed time, beside the tokens
  5. Pool, then divideTotal usage over accepted changes. With none accepted, there’s no rate

What we do now: every record shows tokens per attempt beside attempts per accepted change, so a cheap attempt that keeps retrying shows up.

That count says what a change cost, not whether each step on its way did its job.

Readers asked about five of those steps, so I tested each with a small study, committed before or as it ran.

Don’t rely on a warning that matches names

“When the duplicate warning fires, does the agent switch to the existing code?”From leo_heo on Reddit

Mostly there was nothing to switch to. A hook warned my agents whenever new code took an existing name. It kept no log, so I recovered its 39 warnings from transcripts.

34 of 39 warnings were false alarms

False alarms34
Real copies5none reached main
Every duplicate-name warning from the hook I deleted, recovered from transcripts.

Most false alarms were classes overriding one method, which share a name by design. In two of the five real copies, the agent dropped its copy for the existing code 20 seconds after the warning.

Two runs each way can’t say whether the warning helps

Same name, warning on: reused it2 of 2
Same name, warning off: reused it1 of 2
A decoy with the same name: not misled4 of 4
Different name: reused it0 of 4the warning never fired
12 runs of three small tasks, each run twice with the warning on and twice with it off.

What we do now: the name warning stays retired. My quick count before retiring it missed the two times it helped, but it never fires on a copy with a different name, and those got through all four times.

So the copies that matter have to be caught by their code.

Check for copies by their code

“If an agent copies existing code under a different name, do the duplicate checks catch it?”From ChemicalExcellent463 on Reddit

No. Before review, a change must pass a done gate, which runs the project’s own checks, duplicate checks included.

Matching on names missed every copy with a different name

0 of 3
copies under a different name caught by the checks I was running
3 of 3
same-name pairs doing different jobs, flagged anyway
14 pairs of functions, written from specs by two authors who chose every name. Six were copies, three under different names, and that was committed before any check ran.

A free cross-file tool, jscpd, caught two of the three by the shape of the code. My checks had matched names or looked within one file, and Rigby’s done gate couldn’t tell 1 clone from 2.

What we do now: one project’s done gate runs jscpd across every file and fails only on copies a change adds. Near-copies are reported, not blocked: only 1 in 10 I checked was a real copy. My other projects move next.

Whatever the checks miss, the reviewer is the last line before a merge.

Test your reviewer on changes you know are correct

“After an endpoint is renamed, does a clean-looking diff fool the reviewer?”From a blog reader

No, but it overcorrects. Rigby’s reviewer, another agent, checks each change before it merges. I built one endpoint rename four ways, two correct and two broken, and had it review each six times.

Independent checkReviewerFALSE BLOCKThe work was correct. The reviewer sent it back.

An illustration of a catch and a false block, not a real review

It caught the broken versions in all 12 of their reviews, naming the file. Had I only tested it on broken changes, it would have looked perfect.

It also blocked 4 of 12 correct changes, each time because the project had no API index, a list of which code owns what.

The reviewer blocked every broken version, and some correct ones

Broken: a caller left on the old route6 of 6
Broken: a second copy of the endpoint6 of 6
Correct: callers moved to the new route5 of 6
Correct: old route kept as an alias3 of 6
Right verdicts in six reviews of each version: three with the code to reuse named in the brief, three without.

m-ritter suggested on Reddit naming the exact code to reuse. It didn’t change the score: with or without it in the brief, the reviewer got 10 of 12 verdicts right.

What we do now: two of those blocks quoted a line in our own brief saying the project had no API index. The brief now says that’s the project’s gap, not the change’s, so it’s no reason to block. Rerunning the 24 reviews will show whether that worked.

Count each fix once, not once per file

“If one failure keeps coming back in different files, does the reminder that flags repeated fixes see it?”From ASIREXLABS on Reddit, who suggested tagging each fix with its failing test

Not tested yet. When fixes pile up in one file, a reminder asks the agent to redesign. I replayed 60 days of fixes to the disk-cleanup code from the band-aids article.

The replay never saw a failure move to a new file

14 of 21
fixes flagged counting by file, mostly unrelated fixes in one busy file
1 of 21
flagged when counting by the failing test instead
0
failures that moved to a file nobody had touched
One disk cleanup: six files over 60 days, labelled before either count ran.

Counting by the failing test flagged far fewer fixes than counting by file. The replay also caught a mistake in my own count.

The 29 band-aids were 21 fix commits

Fix-to-file touches29
Distinct fix commits21
The same cleanup, counted two ways.

What we do now: count each fix once. The band-aids article counted a fix once for every file it touched, turning 21 fix commits into 29, and said 47 commits where I can find 38. It now carries the correction.

Tell an agent working alone how to decide

“If the agent gets the old bugs as tests it can run, does its redesign keep them fixed?”From Far_Reindeer8428 and Majestic_Tailor8036 on Reddit

Still unanswered. That disk cleanup, the code that deletes old build files so the disk doesn’t fill, took 21 fixes before its main file was redesigned: rebuilt simpler instead of patched again.

Six of those fixes each stopped a bug in that file. But a redesign throws code away, and some of it was there to stop those bugs coming back.

These readers suggested giving the agent the old bugs as tests, so it knows what has to keep working.

How I tested their idea

  1. Wind the project backTo just before the real redesign, so every agent starts where it started
  2. Ask agents to redesign it aloneNobody watching, and nobody to answer their questions
  3. Give half of them testsTests for three of the six old bugs. The other three are never mentioned, to see what a redesign drops when nobody says to keep it
  4. Score every run the same wayWritten before any run: finished means fewer lines and branches, with all three tests passing. Then count which of the six bugs came back

In round one, two agents with tests and two without all stopped without changing a thing, to ask me which behaviour to keep. The reminder my setup adds after repeated fixes, asking for a redesign, also said to check with me first, and I wasn’t there.

In round two I added a line saying nobody would answer, and ran four more. Both agents with tests stopped again rather than break a test.

One without tests copied the real redesign from the project’s later history, which its copy still held, so I threw that run out. The last committed its code, but brought back three of the six old bugs.

Rounds one and two: 8 runs, no finished redesign

0
runs that finished the redesign
1
run thrown out for copying the real redesign from later history
3 of 6
old bugs back in the one valid run that changed code, which had no tests

Round three was eight more runs in clean copies holding nothing after the start, so no agent could find the real redesign. This time the reminder itself said to decide.

All four with tests stopped again: two asked me anyway, and two said they couldn’t keep the tests passing. All four without tests committed new code, said what they’d chosen, and brought back two to six of the old bugs.

Round three: with the tests they stopped, and without them old bugs came back

0 of 4
agents with the tests that changed any code
4 of 4
agents without them that committed new code
2 to 6
old bugs, of six, back in each of those rewrites
8 runs in clean copies. That makes 16 runs, and none has finished the redesign.

Something may have to give. Every agent without tests noted that Cargo can’t prune old builds by age or size, and the real redesign itself dropped two of the six fixes on purpose.

What we do now: when nobody can answer, the reminder tells the agent to decide: keep every behaviour the earlier fixes protect, even if that means a smaller redesign, and say what it chose. Whether the tests make a redesign safer is still open, because no agent with them has done one.

How far to trust it

No study here measured savings on real work

  1. Small samplesTwo to four runs per condition, 24 reviews and 14 name pairs
  2. Errata stay visibleMy wrong band-aid count, and a label the replay missed, are both on the record
  3. Still openSafer redesigns, and earlier detection of loops across files
  4. What they did doThey helped repair the measurement

Try it on one kind of task

Start with one recurring kind of task and record what it costs today. Then make one of these changes at a time:

  1. Pool every attempt’s tokens, with the brief and the review, and divide by accepted changes.
  2. Run a cross-file duplicate checker such as jscpd, failing only on copies a change adds.
  3. Give your reviewer correct and broken versions of one change, several times each, and count its false blocks.
  4. Count fixes per commit, and name the unit you counted.
  5. Tell any agent working alone that nobody can answer, and to keep every behaviour earlier fixes protect.

The series guide has a brief you can copy and a scorecard for comparing one change at a time.

How I ran the studies

Each study committed its expected answers before or as it ran, and kept its errata visible after. These twelve checks kept them honest, and I’d use them again.

  1. Score what the agent did after a warning, not just whether it fired.
  2. Commit expected answers before either method runs. Keep later errata visible.
  3. Choose test names without seeing the detector.
  4. Use independent executable checks and deliberately broken controls.
  5. Try the simplest case the tool claims to catch.
  6. Count distinct items, with a clearly named unit.
  7. Hold back regression cases from both briefs.
  8. Isolate the repository’s history so future commits cannot leak in.
  9. Tell unattended agents how to decide when nobody can answer.
  10. Pool usage and accepted changes before dividing. Include failures.
  11. Join accepted work to the Git record of its task and review.
  12. Get an independent design review, then verify its claims.

What changed in the records

  1. Merge messages name the workEach identifies the task and its reviewers
  2. Daily records count landed workWhole UTC days, repeated usage totals deduplicated, only work landed by the cutoff
  3. The report claims lessThe morning report’s lines check now claims only what it shows

Next come the same duplicate gate for my other projects, a search that shows the agent existing code before it starts, and a public throughput chart.