fix(proxy_server): populate model_info when cost keys are present but None (#40741) - #40756
Open
tusharjamunkar wants to merge 2 commits into
Open
Conversation
Contributor
Greptile SummaryThis PR updates both model-info enrichment paths to populate metadata whose existing value is
Confidence Score: 5/5The PR appears safe to merge, with focused regression coverage for both affected enrichment paths. No actionable new issues remain. The previously reported test gap is resolved by independently invoking
|
| Filename | Overview |
|---|---|
| litellm/proxy/proxy_server.py | Both model-info merge sites now treat missing and None values as unset while preserving non-None overrides. |
| tests/test_litellm/proxy/proxy_server/test_routes_model_info.py | Adds independent regression tests for both merge paths and coverage for preserving custom pricing. |
Reviews (2): Last reviewed commit: "test(proxy_server): add independent regr..." | Re-trigger Greptile
Contributor
…del_info with fresh model
Author
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
TLDR
Problem this solves:
ModelInfoserialization dumps fields withNonevaluesproxy_server.pycheckedif k not in model_info:Nonevalues blocked model cost map enrichmentHow it solves it:
if model_info.get(k) is None:at both merge sitesNonefields get enriched with litellm cost dataUser Flow
Before: a proxy user configures a model deployment without explicit per-token pricing, and concurrent budget reservations fail to estimate spend, allowing requests through with $0 estimated spend
ModelInfofields (whereinput_cost_per_token=None, etc.)proxy_server._enrich_model_info_with_litellm_dataseesk in model_info(with valueNone) and skips filling in litellm's default pricingNone, leading concurrent request budget reservations to evaluate spend at $0.0After: the proxy initializes the model deployment, enriches unset/
Nonefields with standard model pricing, and preserves any custom pricing overridesModelInfoproxy_server._enrich_model_info_with_litellm_datachecksif model_info.get(k) is None:and populatesinput_cost_per_token,output_cost_per_token, and other metadata from the default cost mapRelevant issues
Fixes #40741
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
Before (dfab479)
_enrich_model_info_with_litellm_datawith defaultProxyModelInfoinput_cost_per_token: None,max_tokens: None,mode: None(pricing was skipped because keys were present withNonevalue)After (80f4d7e)
_enrich_model_info_with_litellm_datawith defaultProxyModelInfoinput_cost_per_token: 5.5e-06,max_tokens: 128000,mode: 'chat'(pricing and token limits populated from cost map)input_cost_per_token: 0.00099is preservedType
🐛 Bug Fix
✅ Test
Caveats (if any)
Final Attestation