記事一覧

Measuring Long-Running Coding Agents, Part 2: Return on Token, Rework Costs, and the Three-Round Cutoff

2026年11月23日

#Artificial Intelligence#Software Engineering#ai agents#metrics#finops
Measuring Long-Running Coding Agents, Part 2: Return on Token, Rework Costs, and the Three-Round Cutoff

In Part 1, we looked at why activity metrics mislead on multi-day agent builds, how we score a build from evidence instead of an agent's own summary, and how a 20-minute library swap turned into 41 tasks that posted better review numbers than a well-scoped feature. This part turns those lessons into a metric, Return on Token, and then follows the math to two practical rules: rework is far more expensive than it looks, and three review rounds is the right place to stop patching.

Defining Return on Token (RoT\mathrm{RoT})

First, keep human effort completely out of Return on Token. Human attention belongs on its own axis, which we cover in Part 3. Return on Token measures one thing: how efficiently autonomous agents convert tokens into forward-moving verified progress rather than rework and ceremony.

Declare four raw quantities, all directly observable in build records:

  • $F$ (Forward task completions): Count of tasks that passed verification and merged (tasks completed on the scorecard). (Unit: tasks, integer ≥0\ge 0.)
  • $A$ (Accepted acceptance criteria): Count of specification criteria verified met (Criteria met on the scorecard—the value threads that exited the tunnel intact). (Unit: criteria, integer ≥0\ge 0.)
  • $R$ (Rework rounds): Count of failed task review rounds, retries, or discarded attempts along the way. (Unit: task rounds, integer ≥0\ge 0.)
  • $C$ (Token cost): Total tokens (in millions) or cache-adjusted effective units spent across all forward and rework rounds. (Unit: 1M tokens, 1M effective units, or $.)

(One crucial accounting detail on $C$: across Epic B, 89.2% of our 251.2M recorded judge input tokens hit prompt cache—peaking at 92.3% on Round 1B. Because cached reads cost roughly 0.1×0.1\times uncached input and 0.02×0.02\times output tokens, measuring $C$ in cache-weighted effective units—1.0⋅uncached+0.1⋅cached+5.0⋅output1.0 \cdot \text{uncached} + 0.1 \cdot \text{cached} + 5.0 \cdot \text{output}—prevents thick, well-cached architectural context from looking artificially expensive.)

From $F$ and $R$, define Forward Efficiency η\eta (eta, standard physics notation for useful-to-total efficiency):

η=FF+R∈[0,1]\eta = \frac{F}{F + R} \in [0, 1]

(Both $F$ and $R$ count task rounds, so η\eta is a pure unitless fraction—identical to cycle pass rate on the ETC scorecard.)

Scaling to Multi-Task Builds: Two Diagnostic Variants

Dividing η\eta by cost per completed item (C/FC / F or C/AC / A) keeps the metric scale-invariant from 1 task up to 50 tasks—and creates a clean diagnostic pair:

  1. Task-Level Return on Token (RoTtask\mathrm{RoT}_{\text{task}}) — Worker Execution Efficiency: RoTtask=ηC/F=F⋅ηC\mathrm{RoT}_{\text{task}} = \frac{\eta}{C / F} = \frac{F \cdot \eta}{C}
  2. Spec-Level Return on Token (RoTspec\mathrm{RoT}_{\text{spec}}) — Value-Thread Efficiency: RoTspec=ηC/A=A⋅ηC\mathrm{RoT}_{\text{spec}} = \frac{\eta}{C / A} = \frac{A \cdot \eta}{C}

Notice their exact ratio identity:

RoT<em>specRoT</em>task=AF\frac{\mathrm{RoT}<em>{\text{spec}}}{\mathrm{RoT}</em>{\text{task}}} = \frac{A}{F}

Putting both variants side by side catches Goodhart gaming immediately:

  • When both $\mathrm{RoT}{\text{task}}$ and $\mathrm{RoT}{\text{spec}}$ are high, tasks are right-sized and workers are executing cleanly.
  • When $\mathrm{RoT}{\text{task}}$ is high while $\mathrm{RoT}{\text{spec}}$ drops (like our 41-task Textual swap), workers executed fine—the planner over-shredded the work, burning tokens across too many splices per real requirement (A/F≪1A / F \ll 1).
  • When both drop together because η\eta plunged, workers are hitting missing interface contracts or carrying oversized tasks.
  • And when 507 tool turns run at 99.1% tool efficacy with zero merged tasks (F=0,A=0F = 0, A = 0), both equal 0.00.

Reading the two Return on Token numbers together. Task-level up and spec-level up: right-sized tasks, clean execution. Task-level up, spec-level down: the planner over-split the work, as in our 41-task Textual swap. Both down: workers are struggling, eta plunged from missing interface contracts or oversized tasks. Both zero: nothing shipped, as in 507 tool turns at 99.1% success with zero merged tasks.

Why Rework Costs Grow Quadratically

Look closer at RoTtask=F⋅ηC\mathrm{RoT}_{\text{task}} = \frac{F \cdot \eta}{C} and a sharper mathematical truth jumps out: token spend $C$ is not independent of rework $R$.

If each task round (initial or rework) consumed roughly a constant c0c_0 tokens, then total cost across F+RF + R rounds would be C≈c0(F+R)C \approx c_0(F + R). Substitute both η=FF+R\eta = \frac{F}{F + R} and C=c0(F+R)C = c_0(F + R) into the equation:

RoTtask=Fc0(F+R)⋅FF+R=1c0(FF+R)2=η2c0\mathrm{RoT}_{\text{task}} = \frac{F}{c_0(F + R)} \cdot \frac{F}{F + R} = \frac{1}{c_0}\left(\frac{F}{F + R}\right)^2 = \frac{\eta^2}{c_0}

Rework does not degrade Return on Token linearly—it degrades it quadratically (∝η2\propto \eta^2). Dropping cycle pass rate η\eta from 89% (vocab-and-construction-plan) to 57% (207.3) does not trim efficiency by a third; at constant round cost, (0.57/0.89)2≈0.41(0.57 / 0.89)^2 \approx 0.41, slashing effective return per token by nearly 60%.

When we audited every single task lifecycle across Epic B (65 accepted tasks, 96 review cycles, 186 judge rows with zero missing records), we expected context accumulation to make Cycles 2 and 3 even more expensive than Cycle 1. Instead, the data uncovered two opposing forces:

  1. Within the same task, smart harness design cuts marginal judge cost to 0.65×0.65\times: Two optimizations in ETC counteract review bloat. First, judgment_attempt.py feeds fix-round reviewers an incremental delta diff since the prior commit (AC-29). Second, models.py carries forward already-passed reviews via ReusedPass (0 tokens) whenever module boundaries stay untouched. On Task 011-the-sem-reads-one-sentence, architecture passed in Cycle 2 while code review failed; in Cycle 3, ReusedPass skipped the architecture judge entirely, dropping effective judge tokens by 79% (552.9k →\to 389.4k →\to 117.9k). Across all 96 cycles, marginal judge cost averaged αr=0.65×\alpha_{r} = 0.65\times of Cycle 1.
  2. Across cohorts, hitting Round 3 still slashes judge-side RoT\mathrm{RoT} by 7.7×7.7\times due to Tail Selection Bias: Grouping all 65 Epic B tasks by total review rounds K∈1,2,3K \in {1, 2, 3} reveals that tasks reaching Round 3 weren't ordinary tasks having an unlucky day—across their review rounds they drew 3.8×3.8\times the review output (83.7k vs. 21.7k output tokens):
Task Cohort ($K$ Total Review Rounds) Tasks ($N$) Forward Efficiency η(K)\eta(K) Observed Judge Effective Cost Mult. Judge-Side RoT(K)/RoT(1)\mathrm{RoT}(K) / \mathrm{RoT}(1)
K=1K = 1 (Clean 1st-round pass) 38 1.00 1.00×1.00\times (0.71M eff) 1.00x
K=2K = 2 (1 rework round) 23 0.50 1.44×1.44\times (1.02M eff) 0.35x
K=3K = 3 (2 rework rounds, at cap) 4 0.33 2.55×2.55\times (1.80M eff) 0.13x (7.7×7.7\times lower)

Even after incremental diffs and ReusedPass saved 35% per follow-up review—and before even adding unrecorded worker fix turns—sliding from a clean pass (K=1K = 1) into Round 3 (K=3K = 3) collapses Return on Token from 1.00x down to 0.13x. That explains why ETC runs 105,791 sub-100ms mechanical gate checks (34 ms median) before a judge LLM is ever invoked: catching a boundary violation in 34 milliseconds prevents a quadratic token crater downstream.

Line chart across 1, 2, and 3 review rounds (38, 23, and 4 tasks): review cost per task rises 1.00x, 1.44x, 2.55x; forward efficiency eta falls 1.00, 0.50, 0.33; Return on Token, which is eta divided by cost, falls 1.00x, 0.35x, 0.13x.

Why Hard-Capping Rework at 3 Rounds (637 Tasks Audited)

Early on, we set a hard cap of MAX_REVIEW_ROUNDS = 3 in tasks_limits.py on a pragmatic hunch: if an agent cannot pass review after three rounds, we probably specified how—or even what—to build wrong.

Auditing all 637 live tasks across 88 closed task-bearing works in our repository supports that hunch:

  • Cycle 1 pass rate: 392 / 634 = 61.8%
  • Cycle 2 pass rate (given Cycle 1 sent back): 153 / 242 = 63.2% (86.0% cumulative)
  • Cycle 3 pass rate (given Cycle 2 sent back): 68 / 89 = 76.4% (about 96% cumulative)
  • Attempt-2 fresh branch & packet reset: 83 / 91 = 91.2%

Look at what happens at the tail (the 21 tasks that fail Round 3). Allowing a 4th in-place patch round pins forward efficiency at η=0.25\eta = 0.25 while asking a worker to pile yet another patch onto a muddied branch and a flawed prompt.

Instead, ETC enforces two structural rules in tasks_limits.py:

  1. Shared 3-round review budget across attempts: Starting Attempt 2 resets the git branch and re-scopes the task packet, not the 3-round review budget (2 failed review rounds on Attempt 1 leaves 1 review slot on Attempt 2 before forcing a human/architect escalation). That prevents a 2×32 \times 3 loop from secretly turning into a 6-round token sink.
  2. Re-specify rather than patch: On Task 009-the-savepoint-verb in 207.3, architecture review failed twice on Attempt 1 because a sister task (017) belonged in the same boundary. Instead of burning Round 3 taping over the seam, the engineering manager reset onto Attempt 2, folded 017 into a clean packet, and passed both judges on its single remaining review slot. Across the entire repository, resetting the packet on Attempt 2 clears 91.2% of second attempts—turning a rework spiral back into clean forward motion.

What Transfers to Other Harnesses

ETC is our harness, so the specific constants above (about 707k effective judge tokens per task, 0.65× marginal review cost, about 96% of tasks resolved by Round 3) are readings from our instrument. We expect the underlying trade-offs to hold on other multi-agent setups, whether that's a background-agent product or a custom loop of your own.

What is specific to ETC:

  • Baseline per-task overhead (about 707k effective judge tokens): comes from running two independent reviewers (code and architecture) against our standards.
  • Sub-linear rework cost (0.65× per follow-up review): only happens because ETC sends reviewers an incremental diff and skips reviewers that already passed. In a naive chat loop that appends the full history every turn, we'd expect each follow-up review to cost more than the first (we estimate above 1.2×), so rework hurts even more than in our tables.
  • The sweet spot for task size (around 9 on our complexity dial): will shift upward as frontier models get better working memory.

What we expect to hold on any harness:

  1. Rework carries a super-linear penalty. Even a bare agent looping against pytest with no LLM reviewers pays twice for every retry: forward efficiency drops as 1/K, and cumulative tokens grow at least linearly with K. First-pass clarity beats retry speed.
  2. Building the wrong thing, or building it the wrong way, costs far more. The retry penalty above stays bounded, because review catches the problem inside a single task and the three-round cap limits the damage. A wrong specification or a wrong design is different: each task can be correct against its own instructions and pass every review, so nothing gets sent back. The cost shows up later, multiplied across every task that built on the mistake, and in the worst case as work that never ships at all. Our Textual swap is the mild version: the plan, not the workers, turned a 20-minute change into 41 tasks over 35 hours. That's why we spend so heavily on the spec and the first end-to-end slice (Part 3), and why a task that keeps failing review gets re-specified rather than patched.
  3. Task sizing forms a U-curve between splice loss and context collapse. Cut tasks too small and you pay repeated startup, handoff, and shim costs (RoT_spec drops while RoT_task looks great). Cut them past the model's reliable horizon and Cycle-1 pass rates fall off a cliff. Better models move the bottom of the U to the right; they don't remove it.
  4. Strict exit gates move hidden bug debt onto the token meter. Without gates, bad specs look cheap only because broken code ships and people pay the rework bill later by hand. Once a harness holds exit correctness near 100%, the specification and design flaws that review can see have nowhere to hide except extra rounds (R) and extra tokens (C). The ones review can't see are finding #2.

Two other findings hold everywhere too, and we cover them elsewhere: activity metrics drift away from surviving value (Part 1), and dependency chains compound upstream clarity, or upstream slop, across a build (Part 3).

That last point is where Part 3 picks up: why tokens spent on design at the start of a long build pay back across every task that follows, and why human attention needs its own ledger.


AI attribution: 3/4 — Human-originated, AI-shaped. What this means

Jason Vertrees is the founder of Heavy Chain Engineering, which helps lower middle-market vertical SaaS companies and PE firms turn scattered AI usage into measurable delivery leverage — 85% faster feature velocity, six-to-eight-week projects shipped in days. If you want help building an AI-native engineering organization, book an AI Delivery Assessment or email info@heavychain.org.