Skip to content

[litellm-agent] Staging → litellm_internal_staging (5/11/2026) - #27661

Closed
oss-pr-review-agent-shin[bot] wants to merge 5 commits into
litellm_internal_stagingfrom
shin_agent_oss_staging_05_11_2026
Closed

[litellm-agent] Staging → litellm_internal_staging (5/11/2026)#27661
oss-pr-review-agent-shin[bot] wants to merge 5 commits into
litellm_internal_stagingfrom
shin_agent_oss_staging_05_11_2026

Conversation

@oss-pr-review-agent-shin

Copy link
Copy Markdown
Contributor

Automated staging PR created by litellm-agent.

This branch collects PRs approved by the agent on 5/11/2026.

jamesmyatt and others added 4 commits April 27, 2026 10:13
* Include provider in model names for ollama

* Fix unit tests
* fix(health_check): skip max_tokens for image_generation mode

`_update_litellm_params_for_health_check` injected `max_tokens` for
every deployment. OpenAI `/v1/images/generations` strictly rejects
unknown fields, so health checks for dall-e-* and gpt-image-1 always
failed with `400 "Unknown parameter: 'max_tokens'"` even though the
actual image endpoint calls succeed. Skip the `max_tokens` injection
when `model_info.mode == "image_generation"`. `messages` still gets
injected (downstream `_filter_model_params` already strips it for
non-chat handlers).

* Switch to allow-list with per-deployment override

Per @krrishdholakia review: deny-listing image_generation only re-introduces
the same bug for every other non-chat mode (embedding, audio_*, rerank,
video_generation, ocr, search, moderation, ...).

Replace the single image_generation skip with `_MAX_TOKEN_SUPPORT_MODES =
{chat, completion, responses}`. Missing `mode` is treated as chat for
backward compatibility. New modes are safe by default.

Add `model_info.health_check_supports_max_tokens` as an operator escape
hatch — True forces injection on a non-listed deployment (operator wants
to bound probe tokens), False suppresses it on a chat-style deployment
behind a strict-schema provider.

Tests: parametrize over 3 chat-style + 10 non-chat modes, plus override
on/off and the no-mode legacy path.
… multipart uploads (#26718)

Squash-merged by litellm-agent from dawidkulpa's PR.
@oss-pr-review-agent-shin

Copy link
Copy Markdown
Contributor Author

@greptile please review

@greptile-apps

greptile-apps Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This automated staging PR bundles four independent bug fixes: crash prevention in MaskedHTTPStatusError when the request body is streamed, correct dual-field population when an Ollama chunk contains both thinking and content, consistent ollama/ prefix on live-fetched model names, and a mode-based allow-list that stops non-chat health-check probes from injecting max_tokens.

  • http_handler.py: Wraps request.content access in a try/except httpx.RequestNotRead so multipart/streaming requests no longer crash error-masking logic.
  • ollama/chat/transformation.py: Promotes the content branch from elif to if, allowing a single Ollama stream chunk to carry both reasoning_content and content simultaneously.
  • ollama/common_utils.py: Prefixes dynamic API-fetched model names with ollama/, matching the existing static-fallback behaviour; callers that consumed bare names from the live endpoint will see a naming change.
  • proxy/health_check.py: Introduces _should_inject_health_check_max_tokens to gate max_tokens on mode; a previously undocumented side-effect is that an existing health_check_max_tokens value on a non-chat deployment is now silently ignored unless health_check_supports_max_tokens: true is also set.

Confidence Score: 4/5

Safe to merge with awareness that two changes alter observable output for existing users: Ollama model names now carry an ollama/ prefix from the live endpoint, and health_check_max_tokens no longer auto-enables injection on non-chat modes.

Three of the four changes are clean, targeted bug fixes with matching tests and no observable regressions. The health-check change silently drops a previously-honoured config key (health_check_max_tokens) for non-chat deployments without a migration path or compatibility flag, and the Ollama model-name prefix change alters return values for callers consuming the dynamic endpoint. Both are intentional fixes to broken behaviour, but operators who relied on either behaviour will need to update their config.

litellm/proxy/health_check.py and litellm/llms/ollama/common_utils.py are the two files where existing operator configs may need updating after this merge.

Important Files Changed

Filename Overview
litellm/llms/custom_httpx/http_handler.py Catches httpx.RequestNotRead when accessing streaming request body during error masking — clean defensive fix with matching test.
litellm/llms/ollama/chat/transformation.py Changes elif to if so a chunk containing both thinking and content fields populates both reasoning_content and content on the delta — correct bug fix with new test.
litellm/llms/ollama/common_utils.py Adds ollama/ prefix to model names returned by the live /api/tags endpoint, matching the static fallback path; any caller consuming bare model names from the dynamic path will see a breaking change.
litellm/proxy/health_check.py Adds mode-based allow-list gating for max_tokens injection in health-check probes; fixes image/embedding 400 errors but silently drops health_check_max_tokens config for non-chat modes.
tests/test_litellm/proxy/test_health_check_max_tokens.py Comprehensive new tests covering mode allow-list, per-deployment overrides, regression guards for chat/no-mode paths — all mock-only, no network calls.
tests/test_litellm/llms/custom_httpx/test_credential_leak_prevention.py New test validates that streaming request bodies no longer crash MaskedHTTPStatusError construction and that credential masking still applies.
tests/test_litellm/llms/ollama/test_ollama_chat_transformation.py New test for same-chunk thinking+content handling; existing test assertions are unchanged, no coverage weakening.
tests/test_litellm/llms/ollama/test_ollama_model_info.py Existing assertions updated to expect ollama/-prefixed names, correctly reflecting the new consistent prefix behaviour.

Reviews (1): Last reviewed commit: "fix(http_handler): handle RequestNotRead..." | Re-trigger Greptile

Comment on lines +44 to +57
def _should_inject_health_check_max_tokens(model_info: dict) -> bool:
"""
Whether the health-check probe should include `max_tokens`.

Order:
1. `model_info.health_check_supports_max_tokens` (operator override).
2. `_MAX_TOKEN_SUPPORT_MODES`. Missing `mode` is treated as `chat`
for backward compatibility.
"""
explicit = model_info.get("health_check_supports_max_tokens")
if explicit is not None:
return bool(explicit)
mode = model_info.get("mode") or "chat"
return mode in _MAX_TOKEN_SUPPORT_MODES

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 health_check_max_tokens no longer auto-enables injection on non-chat modes

Previously, setting health_check_max_tokens: 50 on any deployment (including mode: image_generation) would cause that value to be injected as max_tokens. After this change, _should_inject_health_check_max_tokens consults health_check_supports_max_tokens (a separate bool key) first, then the mode allow-list. An operator who relied on health_check_max_tokens to bound token usage on a non-chat endpoint that happens to accept the field will silently have it dropped — they now need the additional health_check_supports_max_tokens: true key. This is a backwards-incompatible behaviour change without a migration notice or a compatibility flag. The test at line 241–250 in the test file explicitly documents this dropped behaviour.

Rule Used: What: avoid backwards-incompatible changes without... (source)

…11_2026

Preserve both independent features added in parallel:
- max_tokens mode-gating for health checks (skip injection for image_generation
  and other non-chat modes; per-deployment override via health_check_supports_max_tokens)
- reasoning_effort forwarding for chat-style health-check probes
  (_HEALTH_CHECK_MODES_SUPPORTING_REASONING_EFFORT + health_check_reasoning_effort)

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite Sameerlite closed this May 12, 2026
@Sameerlite

Copy link
Copy Markdown
Contributor

#27733

@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Sameerlite
Sameerlite deleted the shin_agent_oss_staging_05_11_2026 branch May 18, 2026 12:57
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.

6 participants