mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix: increase health check max_tokens from 5 to 16 (#23836)
GPT-5 models enforce a minimum of 16 for max_output_tokens. The current default of 5 still causes health checks to fail for these models. Bump the non-wildcard default to 16 — the smallest value that satisfies all known provider minimums while keeping health checks lightweight. Also tightens the wildcard test assertion from a weak disjunctive check to strict key-absence.
This commit is contained in:
parent
3d2b8fed32
commit
fd3eadbd2e
2 changed files with 8 additions and 9 deletions
|
|
@ -319,7 +319,7 @@ def _resolve_health_check_max_tokens(
|
|||
3. For non-wildcard reasoning routes: BACKGROUND_HEALTH_CHECK_MAX_TOKENS_REASONING
|
||||
from env (if set)
|
||||
4. BACKGROUND_HEALTH_CHECK_MAX_TOKENS (global, any route including wildcards)
|
||||
5. Non-wildcard default: 5
|
||||
5. Non-wildcard default: 16
|
||||
6. Wildcard and nothing from (1)(4): leave unset (caller omits max_tokens)
|
||||
"""
|
||||
explicit = model_info.get("health_check_max_tokens", None)
|
||||
|
|
@ -350,7 +350,7 @@ def _resolve_health_check_max_tokens(
|
|||
return int(BACKGROUND_HEALTH_CHECK_MAX_TOKENS)
|
||||
|
||||
if not is_wildcard:
|
||||
return 5
|
||||
return 16
|
||||
|
||||
return 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 5 for non-wildcard models.
|
||||
Test that max_tokens defaults to 16 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)
|
||||
|
|
@ -22,7 +22,7 @@ async def test_update_litellm_params_max_tokens_default(monkeypatch):
|
|||
|
||||
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
|
||||
|
||||
assert updated_params["max_tokens"] == 5
|
||||
assert updated_params["max_tokens"] == 16
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -48,8 +48,7 @@ async def test_update_litellm_params_max_tokens_wildcard():
|
|||
|
||||
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
|
||||
|
||||
# Should not be set to 1
|
||||
assert "max_tokens" not in updated_params or updated_params["max_tokens"] != 1
|
||||
assert "max_tokens" not in updated_params
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -160,14 +159,14 @@ def test_explicit_health_check_max_tokens_beats_reasoning_specific():
|
|||
|
||||
|
||||
def test_reasoning_specific_falls_through_when_wrong_branch_only(monkeypatch):
|
||||
"""Only non-reasoning key set but model is reasoning → fall back to default 5."""
|
||||
"""Only non-reasoning key set but model is reasoning → fall back to default 16."""
|
||||
monkeypatch.setattr(hc_module, "BACKGROUND_HEALTH_CHECK_MAX_TOKENS", None)
|
||||
monkeypatch.setattr(hc_module, "BACKGROUND_HEALTH_CHECK_MAX_TOKENS_REASONING", None)
|
||||
model_info = {"health_check_max_tokens_non_reasoning": 3}
|
||||
litellm_params = {"model": "openai/o1"}
|
||||
|
||||
with patch.object(hc_module.litellm, "supports_reasoning", return_value=True):
|
||||
assert _resolve_health_check_max_tokens(model_info, litellm_params) == 5
|
||||
assert _resolve_health_check_max_tokens(model_info, litellm_params) == 16
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -180,7 +179,7 @@ async def test_background_split_env_reasoning_vs_non_reasoning(monkeypatch):
|
|||
|
||||
with patch.object(hc_module.litellm, "supports_reasoning", return_value=False):
|
||||
updated = _update_litellm_params_for_health_check(model_info, litellm_params)
|
||||
assert updated["max_tokens"] == 5
|
||||
assert updated["max_tokens"] == 16
|
||||
|
||||
litellm_params2 = {"model": "openai/o1"}
|
||||
with patch.object(hc_module.litellm, "supports_reasoning", return_value=True):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue