Repository navigation
fix(usage): price Claude models by exact version, add Sonnet 5.5, flag unpriced models - #30421
Conversation
…g unpriced models normalizeModelForPricing was an ordered chain of regexes in which a new point release fell through to its major: claude-sonnet-5-5 was billed as Sonnet 5 (cache reads at $0.20 instead of $0.10), and any future opus-5-x / fable-5-x would be too. claude-haiku-5-5 matched nothing and silently added $0 to a total that showed no caveat. The resolver now parses family + major + optional minor (family-first and legacy version-first IDs) and only accepts an exact MODEL_PRICING key, so an unknown version is unpriced rather than borrowing another model's rates. The deliberate opus-4.x -> 4.8 and sonnet-4.x -> 4.6 fallbacks go with it. Adds Sonnet 5.5 and Mythos 5/5.1 rows. Haiku 5.5 stays unpriced: it reprices a whole request above 100K prompt tokens, which daily totals cannot express. The Claude summary now carries hasUnpricedModels (as Codex has since #22073), and both panes share one unpricedCostLabel helper for the caveat. Fixes #30338
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to
|
ELI5
Orca estimates what your Claude usage would cost at API prices. When Anthropic released Sonnet 5.5, Orca didn't know its price and quietly used Sonnet 5's instead, which charges twice as much for cached tokens. Haiku 5.5 was worse: Orca knew no price at all and counted it as free, with no hint that the total was incomplete. This PR makes Orca look up each model's exact price, and say so when it can't.
What Changed
Before
opus-5-6orfable-5-2would have been priced as the older model, again silently.After
claude-3-7-sonnet-…,claude-3-haiku-…, and Cursor-styleclaude-4.5-sonnet. Bedrock's dated Opus 4 id (us.anthropic.claude-opus-4-20250514-v1:0) was priced as Opus 4.8 and now gets Opus 4 rates. Dated Sonnet 4 ids now get Sonnet 4's row, so its over-200K pricing tier applies.How it works:
normalizeModelForPricingused to be a long ordered list of patterns, and a new version fell through to whichever older pattern matched first. It now reads the family, major and optional minor version out of the id; bothclaude-sonnet-4-5and the legacyclaude-3-5-sonnetforms are handled. Date stamps,[1m],-thinking, Bedrock and Vertex wrappers are ignored. It then accepts only an exact key inMODEL_PRICING. Adding a model is now a single table row. The Claude summary gainshasUnpricedModels, and both usage panes use one sharedunpricedCostLabelhelper for the note.Behaviour change: the old rule that priced unknown Opus 4.x as Opus 4.8 and unknown Sonnet 4.x as Sonnet 4.6 is removed. Those versions never shipped, and the rule was the same silent-fallback pattern that caused this bug.
Not in this PR: Haiku 5.5 stays unpriced, and flagged. It charges a higher rate on the whole request once the prompt is over 100K tokens. Orca adds up Claude usage per day before pricing, so it can't tell which requests crossed that line. Pricing it properly needs per-request tracking, which Codex already has (#22360). That is a follow-up.
Why
Adding one row for Sonnet 5.5 would have fixed this ticket, but the next release would break the same way. This is the fifth report of this kind, after GPT-6 Astra, GPT-6 Sol, GPT-6.1 Sol and Sonnet 5.5. Matching only exact versions turns a silently wrong number into a total that is visibly marked incomplete. A test checks that every row in the price table is found by its own name.
Linked Issue
Fixes #30338 (STA-11064)
Visual Proof
Not captured. The only visible change is the existing Codex note "• excludes unpriced models" now also appearing on the Claude cost card and in the Overview's existing partial-cost line, when the selected range includes a model with no price. The renderer change is a shared helper that already-tested Codex code now calls.
Testing
Automated tests added/updated
I manually tested these changes locally (not run in the app)
claude-model-pricing.test.ts: every price-table row resolves to itself; about 20 real id formats (dated, Bedrock, Vertex,[1m],-thinking, legacy and Cursor-style); unknown versions stay unpriced; Sonnet 5.5 rates.claude-usage-report-aggregation.test.ts,store.test.ts,usage-overview-model.test.ts: the unpriced flag in the Claude summary and in the Overview total.Locally:
pnpm tc, oxlint, oxfmt andcheck:code-quality:changedpass. The claude-usage, codex-usage, stats, automations and store-slice suites (471 files) ran with one failure, a store test still expecting the removed Opus 4.x → 4.8 fallback; I rewrote it for the new rule and it passes on its own. The full set was not re-run afterwards.I compared old and new resolver results on about 105 model ids. No id that main priced correctly now gets a different price.
Review
Agent skill upstream boundary
Notes
Platform-independent pricing logic in the main process. SSH: no change; this reads local Claude transcripts only. Compatibility:
hasUnpricedModelsis a new field on a local IPC summary; if it is missing it reads as false. Performance: at most two regex runs per daily row, fewer than before.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)