Skip to content

fix(usage): price Claude models by exact version, add Sonnet 5.5, flag unpriced models - #30421

Merged
Jinwoo-H merged 1 commit into
mainfrom
sta-11064-sonnet-5-5-pricing
Oct 18, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
sta-11064-sonnet-5-5-pricing

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​113 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​93
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​85 $\color{#cf222e}{\Huge{\mathbf{−}}}$​120 $\color{#cf222e}{\Huge{\mathbf{−}}}$​35

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

  • Sonnet 5.5 usage was priced as Sonnet 5, with cache reads at $0.20 instead of $0.10 per million tokens. Claude Code sessions are mostly cache reads, so the estimate ran high (about 29% on a typical mix).
  • Haiku 5.5 usage added $0, and the Claude cost card showed a normal-looking total.
  • Any future point release such as opus-5-6 or fable-5-2 would have been priced as the older model, again silently.

After

  • Sonnet 5.5 has its own price row. Mythos 5 and 5.1 are priced at their Fable equivalents.
  • A model with no exact price row is left out of the total, and the Claude cost card and Overview say so ("• excludes unpriced models"), as Codex already does (fix(usage): price GPT-6 Astra, and declare when the Codex cost total omits a model #22073).
  • Several older names that came back with no price are now priced: claude-3-7-sonnet-…, claude-3-haiku-…, and Cursor-style claude-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: normalizeModelForPricing used 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; both claude-sonnet-4-5 and the legacy claude-3-5-sonnet forms are handled. Date stamps, [1m], -thinking, Bedrock and Vertex wrappers are ignored. It then accepts only an exact key in MODEL_PRICING. Adding a model is now a single table row. The Claude summary gains hasUnpricedModels, and both usage panes use one shared unpricedCostLabel helper 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 and check:code-quality:changed pass. 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Platform-independent pricing logic in the main process. SSH: no change; this reads local Claude transcripts only. Compatibility: hasUnpricedModels is 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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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
@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8df5496f-316d-4ad2-ad40-32cdb34ae3e4
📥 Commits

Reviewing files that changed from the base of the PR and between eaa1ee1 and 9114457.

📒 Files selected for processing: 11
  • src/main/claude-usage/claude-model-pricing.test.ts
  • src/main/claude-usage/claude-model-pricing.ts
  • src/main/claude-usage/claude-usage-report-aggregation.test.ts
  • src/main/claude-usage/claude-usage-report-aggregation.ts
  • src/main/claude-usage/store.test.ts
  • src/renderer/src/components/stats/ClaudeUsagePane.tsx
  • src/renderer/src/components/stats/CodexUsagePane.tsx
  • src/renderer/src/components/stats/unpriced-cost-label.ts
  • src/renderer/src/components/stats/usage-overview-model.test.ts
  • src/renderer/src/components/stats/usage-provider-normalization.ts
  • src/shared/claude-usage-types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📝 Walkthrough

Model pricing now resolves normalized model identifiers only when they match a pricing-table key. Claude usage summaries track named models without pricing entries, and the usage views use that status to mark partial costs and qualify estimated-cost labels. Tests cover the pricing rules, summary status, and overview behavior.

Priority: ➖ Normal

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 91144

The change makes Claude cost estimates stricter and flags models without a price. No concrete merge-blocking issue was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main changes: exact Claude model pricing, Sonnet 5.5 support, and unpriced-model reporting.
Description check Passed The description is detailed and covers the change, rationale, linked issue, testing, visual impact, compatibility, and checklist. It notes that manual testing was not performed, the full test suite wa…
Linked Issues check Passed Issue [#30338] requires a claude-sonnet-5-5 pricing entry with $2/M input, $10/M output, and $0.10/M cache reads. MODEL_PRICING contains that row, and claude-model-pricing.test.ts verifies the c…
Out of Scope Changes check Passed The broader changes remain connected to [#30338]. Exact model resolution prevents future silent fallback errors. Unpriced-model tracking and UI labels identify excluded costs. Pricing rows, normalizat…
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, linked issue, testing, visual impact, compatibility, and checklist. It notes that manual testing was not performed, the full test suite was not rerun after the fix, and visual proof was not captured, but the required information is otherwise mostly complete.

Full details: Linked Issues check

Explanation

Issue [#30338] requires a claude-sonnet-5-5 pricing entry with $2/M input, $10/M output, and $0.10/M cache reads. MODEL_PRICING contains that row, and claude-model-pricing.test.ts verifies the cache-read and rate calculations. Exact-key normalization resolves claude-sonnet-5-5 to that row.

Full details: Out of Scope Changes check

Explanation

The broader changes remain connected to [#30338]. Exact model resolution prevents future silent fallback errors. Unpriced-model tracking and UI labels identify excluded costs. Pricing rows, normalization tests, aggregation tests, and renderer changes support that behavior. No unrelated change is demonstrated by the reviewed summary or focused pricing files.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit 04ce3d3 into main Oct 18, 2026
33 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.

[Bug]: claude-sonnet-5-5 has no pricing entry, so cost falls back to Sonnet 5 rates

1 participant