codeburn/src/guard
Resham Joshi 4307542b62
feat(claude): account for /advisor escalations under the advisor model (#659)
* feat(claude): account for /advisor escalations under the advisor model

Claude Code's advisor tool (/advisor) escalates hard decisions mid-turn
to a stronger model. Those tokens are recorded inside
message.usage.iterations as advisor_message entries with their own model
and are excluded from the top-level message.usage totals. The parser read
only the top-level totals, so advisor spend was silently dropped and never
attributed to the advisor model.

Emit a separate call per advisor_message iteration priced under the
advisor model, preserve those iterations through entry compaction and the
large-line (>32KB) byte-scanner path, and fold advisor cost into the guard
budget. Bump the claude parser and guard cache versions so existing caches
re-parse and pick up the advisor spend.

* test(guard): pin advisor cost fold in the live budget

The guard's advisor fold in computeSessionUsage had no test; dropping
advisorCost from the line cost left all 30 guard tests green. Pins the
fold (advisor line costs more than the same line without iterations)
and the per-message replace semantics under streaming rewrites.
2026-07-16 07:42:49 -07:00
..
cli.ts feat(act): realized savings measurement (codeburn act report) (#606) 2026-07-03 13:04:37 +02:00
flags.ts feat(guard): opt-in session-time hook pack for Claude Code (#605) 2026-07-03 11:54:04 +02:00
hooks.ts fix(guard): dedupe streaming message copies in the incremental cost fold 2026-07-03 12:32:46 +02:00
settings.ts feat(guard): opt-in session-time hook pack for Claude Code (#605) 2026-07-03 11:54:04 +02:00
store.ts fix(guard): dedupe streaming message copies in the incremental cost fold 2026-07-03 12:32:46 +02:00
usage.ts feat(claude): account for /advisor escalations under the advisor model (#659) 2026-07-16 07:42:49 -07:00