fix(proxy): avoid duplicate reasoning capability lookup

Compute supports_reasoning once per non-wildcard health-check resolution path and update the stale default-max-tokens test docstring.

Made-with: Cursor
This commit is contained in:
Sameer Kankute
2026-04-17 12:49:31 +05:30
parent d86c6a5b2f
commit 76c69bb933
2 changed files with 5 additions and 11 deletions
+4 -10
View File
@@ -328,25 +328,19 @@ def _resolve_health_check_max_tokens(model_info: dict, litellm_params: dict) ->
deployment_model = _deployment_model_string_for_health_check(litellm_params)
if not is_wildcard:
try:
is_reasoning = litellm.supports_reasoning(deployment_model)
except Exception:
is_reasoning = False
tokens_reasoning = model_info.get("health_check_max_tokens_reasoning", None)
tokens_non_reasoning = model_info.get(
"health_check_max_tokens_non_reasoning", None
)
if tokens_reasoning is not None or tokens_non_reasoning is not None:
try:
is_reasoning = litellm.supports_reasoning(deployment_model)
except Exception:
is_reasoning = False
if is_reasoning and tokens_reasoning is not None:
return int(tokens_reasoning)
if not is_reasoning and tokens_non_reasoning is not None:
return int(tokens_non_reasoning)
if not is_wildcard:
try:
is_reasoning = litellm.supports_reasoning(deployment_model)
except Exception:
is_reasoning = False
if (
is_reasoning
and BACKGROUND_HEALTH_CHECK_MAX_TOKENS_REASONING is not None
@@ -13,7 +13,7 @@ from litellm.proxy.health_check import (
@pytest.mark.asyncio
async def test_update_litellm_params_max_tokens_default(monkeypatch):
"""
Test that max_tokens defaults to 1 for non-wildcard models.
Test that max_tokens defaults to 5 for non-wildcard models.
"""
monkeypatch.setattr(hc_module, "BACKGROUND_HEALTH_CHECK_MAX_TOKENS", None)
monkeypatch.setattr(hc_module, "BACKGROUND_HEALTH_CHECK_MAX_TOKENS_REASONING", None)