fix(claude): normalize anthropic model variants - #578
Merged
junhoyeo merged 1 commit intoMay 24, 2026
Merged
Conversation
Validation * Validation tier: Tier 2 — narrow runtime change, model canonicalization and pricing alias resolution with focused core tests. * cargo test -p tokscale-core test_normalize_model_for_grouping: PASS * cargo test -p tokscale-core anthropic_prefixed: PASS * cargo test -p tokscale-core claude: PASS * cargo test -p tokscale-core pricing::aliases: PASS * cargo fmt --all --check: PASS * rustup run stable cargo clippy -p tokscale-core --all-targets -- -D warnings: PASS * git diff --check: PASS * git diff --cached --check: PASS * Ledger: not applicable — not required for selected validation tier/change family. * Version: not applicable — not required for selected validation tier/change family. * Not run: full workspace test suite — not required for selected validation tier; touched behavior is covered by core grouping/pricing/Claude tests. Rollback * git revert HEAD
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
3 tasks
Owner
|
@IvGolovach this has been merged to v3.0.0: https://github.com/junhoyeo/tokscale/releases/tag/v3.0.0 thanks for the contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Some Claude usage sources report models as
anthropic/claude-...while existing grouping and pricing paths expect canonical Claude names. Without normalization, equivalent Claude usage can split into separate model rows or miss known pricing aliases. This change keeps attribution consistent without changing parser behavior or token accounting.Diff scope
crates/tokscale-core/src/lib.rscrates/tokscale-core/src/pricing/aliases.rscrates/tokscale-core/src/pricing/lookup.rsBranch integrity
main270d64c4d268d5bcc380690441d6a891687d6794origin/main:0 behind / 1 ahead5393e3d5037f41102936fa102cde0acade368be2 fix(claude): normalize anthropic model variantsValidation mode and proof
Mode 2 - narrow runtime change. The diff is isolated to model normalization and pricing alias lookup, with focused unit tests for the affected Claude paths.
Local validation on the final branch SHA:
cargo test -p tokscale-core test_normalize_model_for_grouping: PASScargo test -p tokscale-core anthropic_prefixed: PASScargo test -p tokscale-core claude: PASScargo test -p tokscale-core pricing::aliases: PASScargo fmt --all --check: PASSrustup run stable cargo clippy -p tokscale-core --all-targets -- -D warnings: PASSgit diff --check origin/main...HEAD: PASS, no outputgit diff --cached --check: PASS, no outputLedger: not applicable - not required for this change family.
Version: not applicable - no package or release version changed.
Remote CI: Pending - not available until the pull request is opened.
Runtime safety
The change only maps recognized Anthropic-prefixed Claude model identifiers to existing canonical Claude names and aliases. It does not change token extraction, session parsing, aggregation math, persistence, or network behavior. Unknown model names still flow through existing fallback behavior. No invariant regression introduced.
Rollback plan
Rollback: revert this PR.
DB downgrade: not applicable.
Data repair: not applicable.
Operational caveats: reverting would restore split grouping or missing pricing for these Anthropic-prefixed Claude variant names.
Known residual risks
No known residual risks. Remote CI should validate the final PR SHA after the pull request is opened.
Summary by cubic
Normalize Anthropic-prefixed Claude model IDs to canonical names so usage groups correctly and pricing lookups use the right rates. Adds aliases for
anthropic/claude4.5/4.6 variants to reuse existing canonical pricing.anthropic/claude-<major>-<minor>-{opus|sonnet|haiku}toclaude-{family}-<major>-<minor>intokscale-coregrouping.anthropic/claude-4-5-*andanthropic/claude-4-6-*so cost lookup matches canonical entries.Written for commit 5393e3d. Summary will update on new commits. Review in cubic