Files
everything-claude-code/tests
Robert Egoian 46e2d58795 fix(cost-tracker): prefer harness cost.total_cost_usd when statusline writes it
The transcript-sum estimate diverges from the harness's API-billed cost on
long sessions and after --resume:
- the hard-coded rate table cannot represent Opus 4.7's >200K-token 2x tier
  or the 1h-cache 2x tier (under-counts);
- summing the full transcript double-counts work across --resume boundaries
  while cost.total_cost_usd is per-process.

Both made the bridge file overshoot real cost by 4-5x, which tripped
ecc-context-monitor's $50 "critical" threshold and made agents halt
prematurely (observed: $73.99 hook value at $15.61 real harness cost).

This change adds an opt-in contract: if a statusline writes
{ts, cost_usd} to <tmpdir>/harness-cost-<session_id>.json on each render,
cost-tracker prefers that authoritative value when fresh (<=300s).
Behaviour is strictly additive — absent a writer, the transcript-sum path
is unchanged.

Tests cover both the prefer-fresh-cache and ignore-stale-cache paths.
2026-05-25 20:29:56 +03:00
..
2026-04-12 12:34:45 +05:30
2026-03-29 21:21:18 -04:00
2026-04-12 12:34:45 +05:30