fix(proxy): use max_completion_tokens for gpt-chat-latest health - #30987
Conversation
|
|
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR fixes Azure
Confidence Score: 5/5The change is narrowly scoped to health-check parameter selection and Azure param mapping; the model-map flag is opt-in and can be overridden at the deployment level. The core fix is correct: health checks for both canonical and suffixed gpt-chat-latest deployments now emit max_completion_tokens, and regular calls for the canonical name benefit too. The reviewer-noted lint CI failure is worth resolving before merge, but the logic is sound and well-tested with mock-only unit tests. The lint CI check is still failing per the reviewer — worth verifying the full pipeline, as black formatting and ruff on gpt_transformation.py were not included in the author's local checks.
|
| Filename | Overview |
|---|---|
| litellm/proxy/health_check.py | Adds _resolve_health_check_model_info to merge model-cost metadata with deployment-level model_info; minor issue: GetModelCostMap.load_local_model_cost_map() called inside loop, reading disk once per missed candidate. |
| litellm/llms/azure/chat/gpt_transformation.py | Adds _should_map_max_tokens_to_max_completion_tokens; works for canonical azure/gpt-chat-latest but suffixed deployment names are not resolved here. |
| model_prices_and_context_window.json | Adds azure/gpt-chat-latest metadata with map_max_tokens_to_max_completion_tokens: true. |
| litellm/model_prices_and_context_window_backup.json | Mirrors the azure/gpt-chat-latest entry in the in-package backup JSON. |
| tests/test_litellm/proxy/test_health_check_max_tokens.py | Adds two mock-only tests covering the metadata path and deployment-level override. |
| tests/test_litellm/llms/azure/chat/test_azure_chat_gpt_transformation.py | Adds two unit tests for map_openai_params translation for flagged and unflagged models. |
| tests/test_litellm/test_utils.py | Adds map_max_tokens_to_max_completion_tokens to the model-price JSON schema validator. |
Reviews (3): Last reviewed commit: "fix(azure): health check + chat use max_..." | Re-trigger Greptile
e31f702 to
dfc42a9
Compare
| if candidate in local_model_cost: | ||
| metadata = local_model_cost[candidate] | ||
| break | ||
| except Exception: |
c60a9e7 to
3bd5de9
Compare
|
Thanks for the contribution! Kicking off a Greptile code review on this one. |
There was a problem hiding this comment.
Thanks , this correctly fixes health checks for gpt-chat-latest suffix deployments via model-map metadata.
One gap: this only affects the health probe. Normal /chat/completions calls with max_tokens will still 400 on Azure, because gpt-chat-latest doesn't route through GPT-5/o-series config and AzureOpenAIConfig doesn't translate the param.
Could we add a general model-map flag (e.g. map_max_tokens_to_max_completion_tokens) and use it in AzureOpenAIConfig.map_openai_params as well as health checks, or
Also: unrelated test_openapi_compliance.py change - intentional or accidental?
Also: Please change the base branch to litellm_internal_staging
… flag Address review on BerriAI#30987: - Replace health-check-only flag with general map_max_tokens_to_max_completion_tokens model-map flag - Apply it in AzureOpenAIConfig.map_openai_params so normal /chat/completions no longer 400 on Azure gpt-chat-latest - Keep health-check probe behavior driven by the same flag - Revert unrelated test_openapi_compliance.py change - Add map_openai_params tests
|
Thanks @Sameerlite, addressed all three points:
|
629df85 to
040d231
Compare
|
Thanks for the contribution! The lint CI check is still failing — could you take a look? Also triggering a fresh Greptile review on the latest commit. |
…t-latest Azure gpt-chat-latest rejects max_tokens and requires max_completion_tokens, but it does not route through GPT-5/o-series config. Add a general model-map flag map_max_tokens_to_max_completion_tokens (azure/gpt-chat-latest) consumed by both AzureOpenAIConfig.map_openai_params (normal /chat/completions) and the proxy health-check probe, so neither path 400s. - Add azure/gpt-chat-latest entry + flag to both model cost maps - AzureOpenAIConfig.map_openai_params translates max_tokens -> max_completion_tokens - health_check merges model-cost metadata (suffix deployments) and routes the bounded probe token to max_completion_tokens when flagged - tests for chat + health paths; schema allowlist updated Rebased onto litellm_internal_staging.
040d231 to
4cc2f97
Compare
|
Good fix direction (metadata flag + map_openai_params), but the cost-map lookup doesn’t match repo patterns. Don’t call GetModelCostMap.load_local_model_cost_map() directly - use litellm.model_cost + _get_bundled_model_cost_map() (see _get_model_cost_entry_for_provider_config in utils.py). Don’t fall back to get_model_info() for this flag - it won’t return map_max_tokens_to_max_completion_tokens. Either read the raw map entry or add the flag to ProviderSpecificModelInfo and use _supports_factory. Health check is overbuilt - _resolve_health_check_model_info duplicates lookup logic and changes more than token params. Simpler path: pass model_info/base_model into litellm_params, keep injecting max_tokens, let AzureOpenAIConfig translate. Tests and the cost-map entry look good. Please simplify the lookup + health-check path and I’ll re-review. |
|
Thanks so much for this fix, @AleksandrLiadov — the |
|
@AleksandrLiadov can your resolve the merge conflicts? i can get it to merge then. |
What
Fix LiteLLM proxy health checks for Azure
gpt-chat-latestdeployments by sendingmax_completion_tokensinstead ofmax_tokens.Azure
gpt-chat-latestrejects health probes containingmax_tokenswith:Deployment names can include suffixes such as
azure/gpt-chat-latest-gs, so the health check now detectsgpt-chat-latestin either:litellm_params.modelmodel_info.base_modeland sends the bounded health token value as
max_completion_tokensfor those probes.Why
The model supports
/chat/completions, but the health check currently marks it unhealthy because it uses the wrong token-limit parameter. This is similar to the existing Azure GPT-5/o-series max token handling issue, butgpt-chat-latestis an alias and does not necessarily trigger GPT-5-specific model-name routing.Related context:
max_tokens— needs translation tomax_completion_tokenslike o-series/gpt-5 #24779 - Azure models rejectingmax_tokensand requiringmax_completion_tokensgpt-chat-latestmodel metadataTests
uv run pytest tests/test_litellm/proxy/test_health_check_max_tokens.py::test_azure_gpt_chat_latest_health_check_uses_max_completion_tokens -quv run pytest tests/test_litellm/proxy/test_health_check_max_tokens.py -quv run ruff check litellm/proxy/health_check.py tests/test_litellm/proxy/test_health_check_max_tokens.pyNote: local
uvemitted a warning parsingexclude-newer = "3 days", but the tests/lint above passed.