You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(relearn): price the recovery turn from measurement, and draw the line against resend
relearn priced a pothole at a flat 1,500 tokens — an unmeasured guess the code
described as 'roughly one extra assistant turn's overhead'. Measured across
271,442 real calls on a live corpus, one claude-code turn costs ~140k tokens
(836 fresh + 138,087 cache-read + 795 out), because a coding turn re-sends the
whole context. The constant was ~15-20x low, which is why relearn read as noise:
~70% of the Review inbox's cards carrying 0.8% of its money.
The constant was standing in for TWO different quantities. Split them, each on
the basis it earned:
* HEAD — the forced retry. A failed tool call makes the model emit a recovery
turn a successful call would not have needed. Now measured per cluster from
the sessions it actually occurred in (median billed cost per call, divided
back through those sessions' own input rate; falls back to the prompt's
input-token equivalents when a corpus records no cost). Floored at the text
constant — a retry carries the error text, so it cannot cost less.
* TAIL — the error TEXT re-read on later calls. ~1,500 tokens really is the
right size for a block of error text, so the constant stays where it was
earned.
THE LINE BETWEEN THE TWO ANALYZERS, now encoded rather than left to prose:
resend prices redundant context inside calls that HAD to happen; relearn prices
a call that should never have happened at all. So relearn CLAIMS the head only.
The tail is re-sent context resend already prices in full, so it stays in the
observed figure, broken out as past_reread_*, and is claimed by resend alone.
A test asserts claim + tail == observed, so neither can drift.
Also fixes an invariant this change would otherwise have broken silently: the
below-threshold residue documents itself as being 'on the same head-term basis
as past_overspend_tokens' and was still multiplying by the text constant. It
now moves with the head, and its test asserts the invariant instead of pinning
the old literal.
Measured effect on a real corpus (55 clusters, unchanged — no new detection):
observed $46.45 -> $186.32 ($32.21 tail disclosed, $146.23 claimed)
residue $5.16 -> $86.30
total $51.61 -> $272.62 (5.3x)
The cross-analyzer rollup is unaffected: relearn's CostProposal carries
past_overspend_usd=None by design and reports observed_cost_* only, so it
contributes $0.00 to the headline and cannot double-count against resend there.
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments