writingmaclulich.com

How to cut rework and cost per task with AI coding agents

Three changes to try for fewer rounds of fixes and a cheaper lead agent

  1. Restart your lead agent instead of compacting itA fresh start reloads 78k tokens where a compaction reloaded about 150k, and calls per task fell from 39.5 to 30.5.
  2. Put the tests the work must add in every briefThe same builder passed review first time 75% of the time, up from 59%. I can’t prove the briefs did it.
  3. Count rounds of fixes per task, not just pass rateTasks needing two or more rounds of fixes fell from 30 to 11, and the dearest task from $63 to $25.
The numbers are mine: one project, the seven days to 4 November against the seven before.

Rework is where agent cost hides

This is for you if you run AI coding agents and want fewer rounds of fixes per task. It’s one week of changes to mine, measured against the week before.

I run them in Rigby, my own harness for running several AI coding agents. A lead agent, a Claude Code session on Opus, plans each task and reviews it. A builder, Codex, writes the code, and a task that fails review goes back for fixes.

In one week my agents needed half as many rounds of fixes per task, and the lead cost a third less per task

63% → 76%
of tasks passed review first time
112 → 65
rounds of fixes, on 19% more tasks (171 → 204)
$3.92 → $2.54
the lead agent’s cost per task, at list prices
One of my projects, the seven days to 4 November against the seven before, with one builder instead of two for six of those days.

Restart your lead instead of compacting

A long session fills the model’s context, so Claude Code compacts it into a summary. My lead came back from every compaction carrying about 150,000 tokens.

A fresh start reloads 78k tokens, where a compaction reloaded about 150k

After a compaction≈150k
After a fresh start78k
Tokens in the lead’s first call after a reset: 40 fresh starts on 1 to 4 November, against compactions on 25 to 28 October.

Now it starts a fresh session at 200,000 tokens, with a short note of where it was. Calls cost the same, but it needs fewer and smaller ones.

Per task, the lead now makes 30 calls instead of 40, and reads 4.7M tokens instead of 8.4M

39.5 → 30.5
model calls per task
8.4M → 4.7M
tokens read per task
211k → 154k
median context per call
The lead agent’s own calls, 1 to 4 November against 25 to 28 October, at about 7 cents a call in both.

Last week I asked whether a fresh start would beat compaction. On this project it has, though the trial’s full week ends on 6 November.

Try it on your own lead: restart at a token limit with a short note of where it was, and compare calls per task before and after.

The other cost is a task that fails review and comes back, which is where the briefs come in.

Put the tests in the brief

Since 27 October each task’s brief lists the tests the work has to add. The builder knows what done looks like before it starts, which probably explains the rise.

The builder that stayed passed review first time 75% of the time, up from 59%

The week before59%
Last week75%
The same Codex builder in both weeks. The one that left passed 74% first time, so losing it didn’t raise the rate.

I can’t prove it. Other changes landed that week too, so I’m calling the briefs the likely cause, not the proven one.

Add the tests to your own briefs the same way, and record first-time passes before and after.

Count rounds of fixes per task

A higher first-time pass rate should mean fewer rounds of fixes, so I counted those too.

Tasks that needed two or more rounds of fixes fell from 30 to 11

The week before30 tasks
Last week11 tasks
Out of 171 tasks the week before and 204 last week.

Every first-time pass skips a second build and a second review. The worst tasks were also the dearest: the most expensive cost $63 the week before, and $25 last week.

Rework is where cost hides, and the first-time pass rate shows it, so count rounds of fixes per task.

How far to trust it

One project, one week, with a lot changing at once

  1. List prices, not my billI pay subscriptions, so the dollars compare weeks and aren’t an invoice
  2. One builder fewerThe second builder ran out of credit on the first day, not by design
  3. Downtime in both weeksTwo days with nothing delivered the week before, and a 6.5-hour weekly-limit stop last week
  4. Ten releases in one weekRigby changed a lot, so I can’t separate the changes cleanly

My other project, Neuma, also passed review first time more often, 56% to 63%. Its lead did much of that week’s work itself through helper agents, which task counts miss, so I’ve left its other numbers out.

Copy these into your briefs and your lead

Both are paraphrases of what mine do, so change the wording to suit your setup. Add this to every task brief:

Tests this task must add:
- <test name>: <what it checks>
Done means these tests exist and pass.

And give your lead agent this rule about its own context:

When your context reaches 200,000 tokens, do not compact.
Write a short note of where you are and start a fresh session from it.

To compare one week with the week before, keep three records:

  1. For every task, who built it, its rounds of fixes, its tokens and its cost.
  2. For the lead, its calls, context and cost per task.
  3. What could mislead the comparison, written down before you claim a result.

How I measured it

Rigby records every task, so a week can be compared with the week before

  1. Every task is loggedWho built it, rounds of fixes, tokens and cost
  2. Weeks are comparedSeven days of records against the seven before
  3. Transcripts check the leadCalls, context and cost per task
  4. Caveats come firstWhat could mislead is written down before any claim

Task figures come from Rigby’s daily ledger, and the lead’s from its Claude Code transcripts, by the same scripts as my earlier audits. Every dollar is a list API price.

Next I’m trying a mode where the lead keeps four helper agents busy and reviews their work itself. I’ll measure it the same way.