fix(server): stop overpricing cached Claude tokens - #244
Merged
Conversation
LiteLLM publishes canonical and provider-qualified rates for the same bare model name. Stripping prefixes before insert let a later entry overwrite the Anthropic cache discount and price cache reads as ordinary input. Keep each rate under its full key. Alias a bare name only when every qualified entry has the same effective rate. Upstream: pingdotgg#8806 Grok 4.6 High in Grok Build via Orca.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummarySummary
No new actionable issues were identified. Confidence Score: 5/5Safe to merge. The earlier pricing issue is no longer outstanding: the lookup now prefers an exact provider-qualified rate and falls back to the bare canonical model name. greptile-apps[bot] resolved the earlier thread without explanation. Reviews (4): Last reviewed commit: "Merge branch 'main' into fix/claude-cach..." | Re-trigger Greptile |
Exact-key lookup left transcripts such as anthropic/claude-fable-5 unpriced when LiteLLM only published the bare canonical rate. Keep provider-qualified rates when they exist, and use the bare canonical rate only when the exact key is missing. Grok 4.6 High in Grok Build via Orca.
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.
Problem
The Usage page can overprice cached Claude tokens when LiteLLM publishes canonical and provider-qualified entries with the same bare model name. The parser stripped provider prefixes before inserting rates, so a later entry without the Anthropic cache discount could overwrite the canonical rate and price cache reads as ordinary input.
Fix
Preserve each LiteLLM rate under its full normalized key. Keep canonical bare entries authoritative. Add a bare alias only when every qualified entry has the same effective rate. Leave genuinely conflicting bare names unpriced.
This is an Akeru adaptation of upstream T3 Code work.
Upstream
Verification
vp test run apps/server/src/usage/usagePricing.test.ts apps/server/src/usage/usageScanCache.test.ts apps/server/src/usage/usageAggregation.test.ts— 30 passedNo UI change. Usage page numbers follow the corrected table.
Model
Grok 4.6 High in Grok Build via Orca.