Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(proxy): avoid duplicate reasoning capability lookup

Sameer Kankute76c69bb933d5
diff --git a/litellm/proxy/health_check.py b/litellm/proxy/health_check.py
index fbe056d41cb..e0664703d28 100644
--- a/litellm/proxy/health_check.py
+++ b/litellm/proxy/health_check.py
@@ -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
diff --git a/tests/test_litellm/proxy/test_health_check_max_tokens.py b/tests/test_litellm/proxy/test_health_check_max_tokens.py
index d5011e51fef..09211b72c3e 100644
--- a/tests/test_litellm/proxy/test_health_check_max_tokens.py
+++ b/tests/test_litellm/proxy/test_health_check_max_tokens.py
@@ -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)