Repository navigation
fix(tests): derive the priced Claude model from litellm's catalog by capability - #19
Merged
Merged
Conversation
…capability The first-party claude-* rows in litellm's price map no longer carry the *_above_200k_tokens tier fields, so no id in the hardcoded candidate list satisfied a test asking for a long-context tier and two test modules failed at collection. Only the Bedrock and Vertex AI Claude rows still carry the tier. anthropic_pricing_model now scans litellm.model_cost for Claude rows that have the requested fields, preferring Anthropic's own rows, then ids without a provider or region qualifier, then alphabetical order, so retiring an id or a field never needs a list edit. The long-context tests in test_counterfactual_pricing and TestLongContextPricing::test_litellm_path ask for a tiered row instead of naming claude-sonnet-4-5, and test_models compares the registry against the catalog instead of a literal $3/$15.
Mearman
marked this pull request as ready for review
October 11, 2026 22:59
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
CI on
mainhas stopped at test collection since litellm's price data changed:tests/test_cost_card_attribution.pyandtests/test_savings_provider_matrix.pyraise "litellm prices none of the candidate models" at import, so everytestshard fails, and three further tests fail onmainfor the same reason. Issues are disabled on this repo, so the explanation is here.The candidates in
tests/_pricing_models.pyare not retired. They are all still inlitellm.model_cost, but the first-partyclaude-*rows no longer carry the*_above_200k_tokenstier fields (the 1M-context beta that carried that premium is gone from the catalog; those rows now havemax_input_tokensof 200000). The tests ask forinput_cost_per_token_above_200k_tokens, so the helper found nothing. Swapping in another first-party id cannot work, because none has the field. The onlyclauderows that still carry it are the Bedrock and Vertex AI ones, for exampleclaude-sonnet-4-5-20250929-v1:0andvertex_ai/claude-sonnet-4-5.test_long_context_derives_the_one_hour_rate_and_says_soand the two above-200k cases ofTestLongContextPricing::test_litellm_pathare the same cause: they usedclaude-sonnet-4-5and assumed the catalog charges a second tier for it, which it no longer does for that row. The product code is correct there (it reads the catalog), so this PR is test-only.The helper now scans the catalog for Claude rows that have the requested fields instead of walking a hardcoded list (first-party rows first, then unqualified ids, then alphabetical, so the pick is deterministic). The two long-context tests request a tiered row.
test_models.py::test_claude_infocompared the picked model against a literal $3/$15, which only held while the list happened to start at Sonnet 4.5, so it now compares against the catalog's numbers.Not changed:
_LONG_CONTEXT_TIERED_MODELSinheadroom/providers/anthropic.pystill applies a 2x premium on the manual fallback path for Sonnet 4/4.5 above 200K, which now disagrees with the first-party catalog. That is product behaviour and needs its own decision, so I left it.Real behavior proof
Setup: worktree of this branch,
env -u HTTPS_PROXY -u NO_PROXY -u no_proxy -u https_proxy uv sync --frozen --extra dev, litellm price data as installed fromuv.lockat the time of the run.Before (
origin/main): the old helper called with the field the tests need.All four ids still in the catalog still lack that field. On
main,pytest tests/test_counterfactual_pricing.py tests/test_providers/test_anthropic.py::TestLongContextPricinggives 3 failures (
assert 3e-06 > 3e-06;0.975 == 1.9125;0.57 == 1.1025).After (this branch):
The neighbouring pricing tests that use the same helper (
test_cost_budget_basis,test_cost_tracker_counterfactual,test_savings_ledger,test_cost_pricing_warning_dedup) also pass. The full suite was not run locally; that is what CI is for.