Synthetic demo data. This report was produced from bundled deterministic scenarios with planted waste patterns. It demonstrates the analyzer; the dollars describe the simulation, not a real bill.
~42%≈ of billed input tokens went to re-sending bytes the model had already seen; the three fixes below recover an estimated $0.35 of $0.52.
Billed tokens per call (exact, from the trace's usage fields): cache reads and writes, uncached input, output.Dollars under each scenario. as-billed and no-cache are exact arithmetic on billed usage; optimal-cache and fixed-cache are simulations on the approx char basis≈.
as-billed: exact: real billed usage priced at published rates (ground truth)
no-cache: counterfactual: every billed input token repriced at the full uncached rate (no cache reads, no write premium)
optimal-cache: simulated (approx): documented cache rules — 300s TTL sliding on read, min-cacheable gate, one breakpoint at end of messages; char-based token split scaled to billed totals; validation: billed cache reads 65974 vs simulated 65974 (agreement 1.000)
fixed-cache: simulated (approx): no repairs supplied — identical to optimal-cache
Billed tokens per call (exact, from the trace's usage fields): cache reads and writes, uncached input, output.Dollars under each scenario. as-billed and no-cache are exact arithmetic on billed usage; optimal-cache and fixed-cache are simulations on the approx char basis≈.
as-billed: exact: real billed usage priced at published rates (ground truth)
no-cache: counterfactual: every billed input token repriced at the full uncached rate (no cache reads, no write premium)
optimal-cache: simulated (approx): documented cache rules — 300s TTL sliding on read, min-cacheable gate, one breakpoint at end of messages; char-based token split scaled to billed totals
fixed-cache: simulated (approx): optimal-cache rules over the breaker-repaired rendering; billed usage totals reused for the token split
Cache breakers (1)
volatile-systemfirst at call index 1 · recovers ≈ $0.12
Fix: move the volatile value (timestamp/UUID/counter) out of the system prompt — inject it in the latest user message instead
system chars [355:374] at call 1: '...reen.\nSession: [session 2026-07-26 14:03:00]\n\nRepository layout:\n ...' -> '...reen.\nSession: [session 2026-07-26 14:03:01]\n\nRepository layout:\n ...'
Billed tokens per call (exact, from the trace's usage fields): cache reads and writes, uncached input, output.Dollars under each scenario. as-billed and no-cache are exact arithmetic on billed usage; optimal-cache and fixed-cache are simulations on the approx char basis≈.
as-billed: exact: real billed usage priced at published rates (ground truth)
no-cache: counterfactual: every billed input token repriced at the full uncached rate (no cache reads, no write premium)
optimal-cache: simulated (approx): documented cache rules — 300s TTL sliding on read, min-cacheable gate, one breakpoint at end of messages; char-based token split scaled to billed totals
fixed-cache: simulated (approx): optimal-cache rules over the breaker-repaired rendering; billed usage totals reused for the token split
Cache breakers (1)
tool-churnfirst at call index 4 · recovers ≈ $0.11
Fix: send tool definitions in one fixed order on every call (sort them once at startup); reordering rewrites the cached prefix
tool order changed at call 4: first seen ['read_file', 'edit_file', 'run_command', 'search_code'] -> ['edit_file', 'run_command', 'search_code', 'read_file']
Billed tokens per call (exact, from the trace's usage fields): cache reads and writes, uncached input, output.Dollars under each scenario. as-billed and no-cache are exact arithmetic on billed usage; optimal-cache and fixed-cache are simulations on the approx char basis≈.
as-billed: exact: real billed usage priced at published rates (ground truth)
no-cache: counterfactual: every billed input token repriced at the full uncached rate (no cache reads, no write premium)
optimal-cache: simulated (approx): documented cache rules — 300s TTL sliding on read, min-cacheable gate, one breakpoint at end of messages; char-based token split scaled to billed totals
fixed-cache: simulated (approx): optimal-cache rules over the breaker-repaired rendering; billed usage totals reused for the token split
Cache breakers (1)
missing-breakpointfirst at call index 1 · recovers ≈ $0.11
Fix: add a cache_control breakpoint (for example on the last message); the stable prefix already meets the minimum cacheable length
calls 0->1 share a byte-stable prefix of ~1641 approx tokens (min cacheable 1024) but cache_breakpoints=0 and billed cache activity is 0
Methodology
Exact vs approximate. Every dollar figure and token total comes from the trace's real billed usage fields (or exact arithmetic on them). Numbers marked ≈ rest on char-based attribution (len/3.7), scaled so segments sum to each call's billed total — useful for proportions, never presented as billed.
Cache simulation rules. 300-second cache TTL, refreshed on read (sliding-window assumption, documented); cache entries are per-model; writes billed at the model's write premium only when a later call in the replay actually reads the entry (an optimal policy never caches what nothing reads back), so optimal-cache never exceeds no-cache; a prefix must meet the model's minimum cacheable length; the simulator places a single cache breakpoint at the end of messages each call (optimal placement). It models the provider's documented rules, not undocumented server behavior.
Redundancy. For each call after the first: the byte-identical rendered prefix shared with the previous call, valued at the call's billed input scaled by char fraction; input already served as cache reads is subtracted (cache reads are cheap — they are not waste).
Scenarios. as-billed = ground truth from usage; no-cache = all input at the full uncached rate; optimal-cache = replay under the documented cache rules; fixed-cache = optimal-cache after neutralizing the detected breakers.
Pricing. Bundled table shipped with tokenbill {{TOKENBILL_VERSION}}, verified 2026-09 against the provider price list. Cache reads are 0.10× base input (0.025× on claude-fable-5-1); dated snapshot ids are priced as their base model. Re-verify before release-grade accounting.