fix(router): don't log 'Could not identify azure model' when the deployment name resolves from the cost map - #33292
Conversation
Greptile SummaryThis PR fixes spurious per-request
Confidence Score: 5/5Safe to merge — the change is restricted to log level selection and does not affect model resolution, cost tracking, or token-limit enforcement. The change touches only one branch inside No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/router.py | Logging-only change in get_router_model_info: downgrades Azure "Could not identify model" ERROR to DEBUG when the deployment name resolves to a cost-map entry with usable (>0) limits or costs. Resolution behavior is unchanged. |
| tests/test_litellm/test_router.py | Adds TestAzureBaseModelFallbackLogging with three new mock-only tests covering the happy path (no error log), the genuine-miss path (error preserved), and the explicit-base-model path. No real network calls; fixture correctly isolates the cost map. |
Reviews (2): Last reviewed commit: "fix(router): use consistent positive che..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@greptileai — made the _fallback_resolves checks consistent: all three fields (max_input_tokens, max_tokens, input_cost_per_token) now require a positive value, so an entry with explicit-zero limits can no longer suppress the error log. |
5801549 to
7e63df3
Compare
7e63df3 to
d2b06c6
Compare
|
Rebased onto |
d2b06c6 to
1362157
Compare
…oyment name resolves from the cost map get_router_model_info already falls back to resolving the azure deployment's model name against the model cost map when base_model is unset — and for deployments named after real azure models (e.g. azure/gpt-4o) that resolution returns correct max tokens and costs. The unconditional ERROR was therefore spurious for exactly the deployments that need no operator action, and on busy proxies it logs thousands of times per day per multi-deployment group. Log at debug when the fallback entry carries usable limits/costs (membership alone is not enough: Router init auto-registers every deployment name as a zeroed stub), keep the ERROR otherwise. Fixes BerriAI#33172 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1362157 to
6c8e319
Compare
…ack gate Review follow-up: token-limit fields used 'is not None' while the cost field used '> 0' — a cost-map entry explicitly storing 0 limits could suppress the error log without carrying usable resolution data. All three checks now require a positive value. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a052a33 to
fa2b896
Compare
|
Closing — superseded by #37869, which merged this branch's commit (authorship preserved) into |
Relevant issues
Fixes #33172
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Production observation (litellm proxy 1.92.0 on Azure, real traffic): every request to a multi-deployment azure group without
base_modellogs— thousands of ERROR lines/day — even though
azure/gpt-5.4is an exact key in the shipped cost map andget_router_model_info's existingif model is None: model = _modelfallback resolves it correctly. We verified on the live proxy that hand-settingmodel_info.base_model = litellm_params.modelon every such row (56 rows on one env) changes nothing about resolution and only silences the log — i.e. the ERROR was spurious for exactly the deployments that need no operator action.While investigating I found membership in
litellm.model_costcan't be the discriminator on its own:Router.__init__auto-registers every deployment name into the map as a zeroed stub (register_model: model=... not in built-in cost map ... will default to 0). The check therefore requires the fallback entry to carry usable limits/costs.Unit tests (new
TestAzureBaseModelFallbackLoggingintests/test_litellm/test_router.py):Before (base
10d5804b3e):test_map_known_deployment_name_resolves_without_error_logFAILS (spurious ERROR fires); other 2 pass.After (this PR,
261f9546c5):covering: (1) map-known deployment name → no ERROR + model_info carries the map's max tokens/costs, (2) genuinely unmappable name → ERROR still logged, zeroed-stub return unchanged, (3) explicit
base_modelstill wins.ruff format --check/ruff checkpass onlitellm/router.py.Type
🐛 Bug Fix
Changes
get_router_model_info's azure branch: whenbase_modelis unset, check whether theazure/<deployment model name>entry in the cost map carries usable limits/costs (guarding against Router-init's zeroed auto-registration stubs). If so, log at debug — the existing fallback resolution handles it. Otherwise keep the existing error.