Skip to content

fix: increase health check max_tokens from 1 to 16 (#23836) - #26217

Closed
hannahmadison wants to merge 1 commit into
BerriAI:litellm_oss_branchfrom
hannahmadison:fix/health-check-max-tokens-23836
Closed

fix: increase health check max_tokens from 1 to 16 (#23836)#26217
hannahmadison wants to merge 1 commit into
BerriAI:litellm_oss_branchfrom
hannahmadison:fix/health-check-max-tokens-23836

Conversation

@hannahmadison

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #23836

Pre-Submission checklist

  • I have added testing in the tests/test_litellm/ directory
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changes

Problem

Health checks set max_tokens=1 for non-wildcard models, which causes failures with newer models like GPT-5 that have minimum token requirements. A single token is insufficient for these models to generate a valid response.

Solution

Increased the default max_tokens from 1 to 16 for health check requests. This provides enough tokens for models to generate a meaningful response while keeping the health check lightweight.

Also tightened the wildcard test assertion from a weak disjunctive check (not in or != 1) to strict key-absence (not in), preventing false passes if a future bug sets max_tokens to an arbitrary value for wildcard models.

Changes Made

  • litellm/proxy/health_check.py: Changed max_tokens default from 1 to 16
  • tests/test_litellm/proxy/test_health_check_max_tokens.py: Updated default assertion to expect 16, tightened wildcard assertion to strict key-absence check

Supersedes #24893 (closed due to branch contamination from upstream merge).

@CLAassistant

CLAassistant commented Apr 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR increases the health check max_tokens default from 1 to 16 in litellm/proxy/health_check.py to fix compatibility with newer models (e.g. GPT-5) that require a minimum token budget to return a valid response. Tests are updated to reflect the new default, and the wildcard model assertion is tightened to strict key-absence.

Confidence Score: 5/5

Safe to merge — minimal, well-tested change with no functional regressions.

The change is a single-line bump of a default constant from 1 to 16. Tests are properly updated, the wildcard assertion is now stricter (not weaker), and all tests remain mock-only. No security, data, or backwards-compatibility concerns.

No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/health_check.py Single-line change: max_tokens default for non-wildcard health checks raised from 1 to 16. Logic and branching are unchanged.
tests/test_litellm/proxy/test_health_check_max_tokens.py Assertions updated to match new default (16) and wildcard test tightened to strict key-absence; all tests use mocks with no real network calls.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[_update_litellm_params_for_health_check] --> B{health_check_max_tokens\nin model_info?}
    B -- Yes --> C[max_tokens = health_check_max_tokens]
    B -- No --> D{"'*' in model or\nhealth_check_model?"}
    D -- Yes wildcard --> E[max_tokens not set]
    D -- No non-wildcard --> F[max_tokens = 16\npreviously 1]
    C --> G[proceed with health check call]
    E --> G
    F --> G
Loading

Reviews (3): Last reviewed commit: "fix: increase health check max_tokens fr..." | Re-trigger Greptile

@hannahmadison
hannahmadison force-pushed the fix/health-check-max-tokens-23836 branch from adcea76 to d53528a Compare April 22, 2026 03:39
Models like GPT-5 have minimum token requirements that cause health
checks to fail when max_tokens=1. Increase to 16, which is enough for
a valid response while keeping health checks lightweight.

Also tighten the wildcard test assertion to verify max_tokens is not
set at all (not just != 1), preventing false passes if a future bug
sets it to an arbitrary value.

Fixes BerriAI#23836
@hannahmadison
hannahmadison force-pushed the fix/health-check-max-tokens-23836 branch from d53528a to 6b9e934 Compare April 22, 2026 03:41
@Sameerlite
Sameerlite deleted the branch BerriAI:litellm_oss_branch April 27, 2026 04:56
@Sameerlite Sameerlite closed this Apr 27, 2026
@hannahmadison

Copy link
Copy Markdown
Contributor Author

Hey @Sameerlite Quick check: was #26217 closed intentionally, or as a side effect of litellm_oss_branch being deleted? If the latter, happy to re-open against main. The change itself is a one-line fix for #23836 and was Greptile-approved at 5/5.

@Sameerlite

Copy link
Copy Markdown
Contributor

It is the latter, please create a new one

@hannahmadison

Copy link
Copy Markdown
Contributor Author

@Sameerlite Will do! Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants