Skip to content

Surface unpriced models instead of silently counting them at $0 - #646

Merged
iamtoruk merged 4 commits into
mainfrom
fix/unpriced-model-visibility
Jul 9, 2026
Merged

iamtoruk merged 4 commits into
mainfrom
fix/unpriced-model-visibility

Conversation

@iamtoruk

@iamtoruk iamtoruk commented Jul 9, 2026

Copy link
Copy Markdown
Member

Fixes #638

Problem

A model missing from the pricing tables contributes $0 to every total, breakdown, export, and MCP response, and the only warning is gated behind CODEBURN_VERBOSE. A new model id shipping ahead of the pricing data (the #629 scenario) silently undercounts real spend.

Change

Render-time detection (findUnpricedModels in src/models.ts): flag aggregated model rows that carry usage but $0 cost and whose pricing lookup yields no billable rate right now. Render-time rather than parse-time because costs are computed at parse time and cached; checking at render covers cached sessions and heals the moment pricing data, an alias, or a price override arrives.

Surfaces:

  • overview: an Unpriced line in Totals with the top offenders and the model-alias fix
  • report/today/month --format json: an unpricedModels array
  • TUI dashboard: a warning footer in the By Model panel
  • MCP get_usage and the menubar payload: a warning line plus unpricedModels in the payload

Correctness notes (from adversarial review)

  • Rows with cost > 0 are never flagged: aggregation keys rows by display name, which the pricing lookup misses, so a priced "Opus 4.8" row would otherwise false-flag.
  • $0 display-name rows ARE flagged even when the raw id prices today: those tokens really entered the report at $0 (e.g. Droid prices the lowercased display name and gets $0; sessions cached before a model's pricing landed).
  • Zero-rate LiteLLM stubs count as unpriced (listed but unknown price). Only an exact zero-rate user override suppresses the flag, because getModelCosts resolves exact overrides before any table hit, so it provably priced the model.
  • Local models, model-savings mappings, and synthetic rows stay excluded: $0 is their correct cost.
  • MenubarPayload.current.unpricedModels is optional; the Swift menubar and web dash tolerate the new key.

Verification

  • 3,052 tests pass, including new cases for the detector, the Droid display-name scenario, zero-rate stubs vs exact/prefix overrides, and overview rendering.
  • Driven end to end on real local data: overview, report JSON, MCP get_usage, and the TUI (captured via PTY) all show the same genuinely unpriced models (gpt-5.6-sol, gpt-5.6-terra, codex-auto-review) and no false flags on priced display-name rows.
  • The TUI capture also caught an 80-column truncation that cut off the fix command; the footer now leads with the command so it survives truncation.
  • Two adversarial review rounds; both MAJOR findings from round one are fixed and pinned by tests, and round two's remaining objection was resolved by restricting suppression to exact overrides.

iamtoruk added 4 commits July 9, 2026 21:04
…d, and MCP

Models missing from the pricing tables silently contributed $0 to every
total with no indication anywhere (the warning was gated behind
CODEBURN_VERBOSE). Add render-time detection that flags aggregated model
rows with usage but $0 cost whose pricing lookup fails right now, and
surface it in overview, report/today/month JSON (unpricedModels), the
TUI By Model panel, and the MCP get_usage summary.

Render-time detection covers cached sessions (cost is computed at parse
time) and heals as soon as pricing data, an alias, or a price override
arrives. Rows with real cost are never flagged: aggregation keys rows by
display name, which the pricing lookup misses; $0 display-name rows are
reverse-resolved to their raw id before flagging so sessions cached
before their model's pricing landed don't get a misleading alias hint.
Local models and model-savings mappings stay excluded: $0 is correct
for them.

Fixes #638
Adversarial review found two false-negative paths and two polish items:

- Drop the reverse-display-name suppression. Droid prices the lowercased
  display name and gets $0, so a $0 row keyed "Sonnet 4.6" is real
  uncounted spend; suppressing it because claude-sonnet-4-6 prices today
  hid exactly the failure this feature exists to expose.
- Treat zero-rate pricing hits as unpriced. LiteLLM ships [0,0] stubs
  for models it lists without a price; a stub hit means unknown price,
  not free. Explicit zero-rate user overrides still count as free.
- Make MenubarPayload.current.unpricedModels optional for source
  compatibility with payload producers that predate the field.
- Replace localeCompare with a byte comparison so tied rows sort
  identically on every host locale.

Refs #638
getModelCosts resolves exact overrides before any table hit, so an exact
zero-rate override provably priced the model and means free. Prefix and
case-insensitive overrides resolve after table hits: a zero-rate stub
shadowed by one still reports $0 from the stub, so it stays flagged.

Refs #638
…truncates

At 80 columns the By Model footer truncated mid-command. The flagged
models are already visible as $0 rows in the table above, so put the
fix command before the names and let the names truncate instead.

Refs #638
@iamtoruk
iamtoruk merged commit 270ee81 into main Jul 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unpriced models silently contribute $0 to totals; warning is off by default

1 participant