Repository navigation
fix: drop duplicate cache_read_input_token_cost_batches keys from the price maps - #42623
Conversation
…key from 23 entries
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d278ac1. Configure here.
TLDR
Problem this solves:
cache_read_input_token_cost_batchestwice in 23 entriestest_price_map_has_no_duplicate_keysfails on main for both filesHow it solves it:
User Flow
Before: a contributor adding a model to the price map runs the schema test and it fails on entries they never touched
model_prices_and_context_window.jsonon a branch off main and runuv run pytest tests/test_litellm/test_model_prices_schema.py -k no_duplicate_keystest_price_map_has_no_duplicate_keys[main]and[backup]both fail withLeft contains 23 more items, first extra item: 'cache_read_input_token_cost_batches'gemini-3.5-flashlistingcache_read_input_token_cost_batchestwice with the same value, so nothing in their own change explains the redAfter: the same test passes and the contributor only sees failures their own change causes
model_prices_and_context_window.jsonon a branch off main and runuv run pytest tests/test_litellm/test_model_prices_schema.py -k no_duplicate_keystest_price_map_has_no_duplicate_keys[main]and[backup]both passcache_read_input_token_cost_batchesonce per entry with the same values as before, so a proxy that fetches the map at boot prices batch cache reads exactly as it didRelevant issues
Cleans up after #42543, #42557, and #42577, which each added the key to the same entries
Affected release
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup: every command runs from a BerriAI/litellm checkout.
dupcount.pyparses a price map from stdin with anobject_pairs_hookand prints how many entries repeat a key:Before (7177d3b)
Schema test
uv run pytest tests/test_litellm/test_model_prices_schema.py -k no_duplicate_keys -p no:cacheprovider --no-covRepeated keys in the published map
curl -sSf https://raw.githubusercontent.com/BerriAI/litellm/7177d3b6d1/model_prices_and_context_window.json | python3 dupcount.py23 entries with a repeated key [('cache_read_input_token_cost_batches', 2)]git show 7177d3b6d1:litellm/model_prices_and_context_window_backup.json | python3 dupcount.py23 entries with a repeated key [('cache_read_input_token_cost_batches', 2)]Parsed maps unchanged
Misc unit shard
Run testsstep of_test-unit-base.ymlwith the misc shard's own test-path fromtest-unit.yml,MAX_FAILURES=10 WORKERS=2 RERUNS=2 TEST_TIMEOUT_SECONDS=120 DIST=loadscope, and the merge base's price maps:no tests ran in 36.46s, exit 0, because that test-path names directories that no longer existgit checkout 7177d3b6d1 -- model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json): all sixFAILED, the same wayAfter (d278ac1)
Schema test
uv run pytest tests/test_litellm/test_model_prices_schema.py -k no_duplicate_keys -p no:cacheprovider --no-cov2 passed, 59 deselected in 0.20sRepeated keys in the published map
curl -sSf https://raw.githubusercontent.com/BerriAI/litellm/d278ac1561/model_prices_and_context_window.json | python3 dupcount.py0 entries with a repeated key []git show d278ac1561:litellm/model_prices_and_context_window_backup.json | python3 dupcount.py0 entries with a repeated key []python3 ci_cd/check_files_match.pyprintsPassed!, so the two files still matchParsed maps unchanged
python3 -c "import json, subprocess; f = '<file>'; base = json.loads(subprocess.check_output(['git', 'show', '7177d3b6d1:' + f])); tip = json.loads(subprocess.check_output(['git', 'show', 'd278ac1561:' + f])); print(base == tip, len(base), base['gemini-3.5-flash']['cache_read_input_token_cost_batches'], tip['gemini-3.5-flash']['cache_read_input_token_cost_batches'])"model_prices_and_context_window.json:True 4179 7.5e-08 7.5e-08litellm/model_prices_and_context_window_backup.json:True 4179 7.5e-08 7.5e-08Misc unit shard
no tests ran in 25.19s, exit 0, unchanged since the workflow file is identical at the merge base and the tip= 6 failed, 6520 passed, 21 skipped, 514 warnings, 11 rerun in 631.21s (0:10:31) =, exit 1PASSED tests/test_litellm/test_model_prices_schema.py::test_price_map_has_no_duplicate_keys[main]andPASSED tests/test_litellm/test_model_prices_schema.py::test_price_map_has_no_duplicate_keys[backup]test_utils.py::test_aaamodel_prices_and_context_window_json_is_valid(fixed on main by test(utils): accept the per-size image cost keys in the price-map schema check #42612),test_cost_calculator.py::test_completion_cost_image_generation_registered_deployment_price_keeps_map_token_rates(fixed on main by test(cost_calculator): point image-generation deployment price test at a live gemini row #42615),test_router_per_deployment_num_retries.py::TestNoProviderRetryAmplification::test_direct_completion_still_forwards_num_retries_to_provider,test_redact_string_in_error_paths.py::TestOpenAIRealtimeRedaction::test_invalid_status_code_redacts_reason,test_redact_string_in_error_paths.py::TestAzureRealtimeRedaction::test_invalid_status_code_redacts_reason, andtest_main.py::test_openai_env_base[OPENAI_API_BASE](the four tracked in ci(test-unit): drop dead misc shard paths and skip missing paths with a warning #42603)Type
🐛 Bug Fix
Caveats (if any)
Low
Final Attestation
Note
Low Risk
JSON-only deduplication with identical values; no runtime code changes and batch cache-read pricing behavior stays the same after parse.
Overview
Removes duplicate
cache_read_input_token_cost_batchesentries from 23 model blocks inmodel_prices_and_context_window.jsonandlitellm/model_prices_and_context_window_backup.json. Each affected model (Gemini 3.x / Vertex variants,deep-research-pro-preview-12-2025, and several GPT-5 dated entries) had the key listed twice after overlapping PR merges; this keeps a single copy per model.Parsed pricing is unchanged because both copies used the same values—this only restores valid JSON and makes
test_price_map_has_no_duplicate_keyspass again on main and backup maps.Reviewed by Cursor Bugbot for commit d278ac1. Bugbot is set up for automated code reviews on this repo. Configure here.