fix(pricing): avoid slow fallback for display model aliases - #1315
Conversation
Resolve pricing and context limits from the original model before falling back to CCUSAGE_MODEL_ALIASES. This keeps display-oriented aliases such as claude-opus-4-8=mythos-5 from forcing an unnecessary models.dev lookup while preserving private-slug aliases that map unknown raw models to known pricing entries. Add a regression test covering known original models with unknown display aliases.
|
no API key found — this repo is configured to use To fix: add the key as a GitHub Actions secret (referenced from your workflow's Open repo secrets → · Configure model → · Setup docs → · Ask in Discord →
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesAlias Lookup Precedence Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
@ryoppippi I have started the AI code review. It will take a few minutes to complete. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | ee69618 | Commit Preview URL Branch Preview URL |
Jun 14 2026, 06:24 PM |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get PR details
gh pr view 1315 --repo ccusage/ccusage --json title,body,files,additions,deletions,commits
# Get PR diff
gh pr diff 1315 --repo ccusage/ccusageLength of output: 7864
Review of
|
Address review feedback: the variable holds the alias's resolved target, which is used as the fallback lookup key. Renaming makes the intent clearer at the call sites. Co-authored-by: Codesmith <[email protected]>
ccusage
@ccusage/ccusage-darwin-arm64
@ccusage/ccusage-darwin-x64
@ccusage/ccusage-linux-arm64
@ccusage/ccusage-linux-x64
@ccusage/ccusage-win32-x64
commit: |
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rust/crates/ccusage/src/pricing.rs (1)
1821-1835: 💤 Low valueTest validates main use case; consider edge case coverage.
The test correctly verifies that a known original model (
claude-opus-4-8in primary table) with a display alias (mythos-5) returns the original pricing, preventing unnecessary alias lookups.For more comprehensive coverage, consider adding tests for:
- Private slug alias: unknown original → known alias (e.g.,
private-model -> gpt-5.5)- Embedded-only model with alias: model only in embedded pricing with display alias
These would validate that the fallback logic works correctly across all intended use cases.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/crates/ccusage/src/pricing.rs` around lines 1821 - 1835, The test `pricing_lookup_prefers_known_original_model_before_alias` covers the case where a known original model has a display alias, but lacks coverage for important edge cases. Add two new test functions: one that validates the private slug alias use case where an unknown original model is aliased to a known model (e.g., private-model maps to gpt-5.5), and another that validates the embedded-only model scenario where a model exists only in the embedded pricing table and also has a display alias. These new tests should follow the same pattern as the existing test, setting up the appropriate model aliases and verifying that the pricing lookup and context limit functions return correct values for these different scenarios.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@rust/crates/ccusage/src/pricing.rs`:
- Around line 1821-1835: The test
`pricing_lookup_prefers_known_original_model_before_alias` covers the case where
a known original model has a display alias, but lacks coverage for important
edge cases. Add two new test functions: one that validates the private slug
alias use case where an unknown original model is aliased to a known model
(e.g., private-model maps to gpt-5.5), and another that validates the
embedded-only model scenario where a model exists only in the embedded pricing
table and also has a display alias. These new tests should follow the same
pattern as the existing test, setting up the appropriate model aliases and
verifying that the pricing lookup and context limit functions return correct
values for these different scenarios.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 104cba6a-eba4-44d1-9267-e762591c1e1a
📒 Files selected for processing (1)
rust/crates/ccusage/src/pricing.rs
ccusage performance comparisonPR SHA: This compares the Rust PR release binary against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
ccusage performance comparisonPR SHA: This compares the PR package against the configured base package on the same CI runner. Package runtime diagnosticsCompares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself. Fixtures: Claude
Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Artifact size
Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |

Fixes model alias pricing lookup so display-oriented aliases do not force slow online pricing fallback when the original model is already known.
Previously, CCUSAGE_MODEL_ALIASES replaced the model before pricing/context lookup, so aliases such as claude-opus-4-8=mythos-5 tried to price mythos-5 and could block on models.dev. The lookup now prefers the original model first, then falls back to the alias target for private raw slugs that need canonical pricing.
Testing:
Need help on this PR? Tag
/codesmithwith what you need. Autofix is enabled.Summary by cubic
Prefer the original model over its display alias when resolving pricing and context limits to avoid unnecessary online fallback and speed up lookups. Preserves canonical pricing for private raw slugs while preventing blocking calls for display-only aliases.
Bug Fixes
claude-opus-4-8resolves locally even if aliased tomythos-5.Refactors
resolved_aliasfor clearer intent.Written for commit ee69618. Summary will update on new commits.
Summary by CodeRabbit