Repository navigation
fix(router): skip declared text-only deployments for image requests on every routing strategy - #48241
Conversation
…ithout enable_pre_call_checks Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…led vision leg falls back to the text leg Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai review |
|
bugbot run |
[Medium impact] The PR appears safe to merge, with the remaining numbered finding addressed SummaryImage requests now skip declared text-only deployments after pre-call checks in both routing paths. Error responses can also read the deployment ID from chat request metadata. The latest changes add
Reviews (3) · Last reviewed commit: "test(router): mark the remaining locals ..." · Reviewed by Greptile |
Merging this PR will not alter performance1 warning
Comparing |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…he new tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai review |
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai re-review please |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 891ae74. Configure here.
Image requests in a model group that mixes vision and text-only deployments no longer land on a text-only deployment. The router already knew how to skip deployments declared
supports_vision: false, but only whenenable_pre_call_checks: truewas set, which almost nobody sets, so a latency-routed group with an OpenAI vision model and a Bedrock gpt-oss model kept sending images to gpt-oss and returning its 400. The skip now runs on every routing strategy by default, and chat completion errors now carryx-litellm-model-idso you can tell which deployment failed.Details
TLDR
Problem this solves:
enable_pre_call_checks: truex-litellm-model-id, so the failing deployment was unknownHow it solves it:
_pre_call_checksand runs on every request, right after the pre-call block and before order filtering and strategy selectionsupports_vision: false, unknown stays eligiblemaybe_get_model_idalso reads the chat request metadata the router fills inUser Flow
Before: a user sending an image to a mixed
mixedgroup gets a Bedrock 400 on most triesmixedwithopenai/gpt-5.6andbedrock/openai.gpt-oss-120b-1:0underlatency-based-routing, nothing else setimage_urlpart400 This model doesn't support the image content blockwith nox-litellm-model-idheaderAfter: the same request always reaches the vision deployment
image_urlpartx-litellm-model-idnames the OpenAI deployment, the same on POST /v1/responses withinput_imageLinear ticket
Resolves LIT-9792
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreScreenshots / Proof of Fix
Live proxy, real OpenAI and Bedrock calls, no mocks. Config used for both runs:
Each case loops the same curl and prints the status line, the
x-litellm-model-idheader and the first line of the body:Before (e6a32bb)
Chat completions with image_url
Responses with input_image
Text request
After (a3b0109)
Chat completions with image_url
Responses with input_image
Text request
Chat completions with image_url while the vision deployment is in cooldown
Same config with
api_key: sk-not-a-real-keyon the OpenAI deployment, so its 401 puts it in cooldown and the image has to land on the text-only deployment. Before, the three Bedrock 400s came back with nox-litellm-model-idAfter, the same 400 names the deployment that failed
This cooldown case is why the filter runs late, on the candidates that survived the cooldown, blocked and pre-call filters, rather than inside
_common_checks_available_deployment. An earlier revision ran it before them and this request returned429 No deployments availableinstead. For the same reason it also runs after_pre_call_checks, so withenable_pre_call_checks: truea context-window rejection of the last vision leg still leaves the text legs as candidates (test_router_sends_an_image_to_the_text_only_leg_when_pre_call_checks_drop_the_vision_leg, which raisesContextWindowExceededErrorwhen the filter runs earlier)Mutation check: removing both
_without_declared_text_only_deploymentscalls fromget_available_deploymentandasync_get_available_deploymentturnstest_router_picks_the_vision_leg_for_image_requests_without_enable_pre_call_checksandtest_async_router_picks_the_vision_leg_for_responses_images_without_enable_pre_call_checksredType
🐛 Bug Fix
Caveats (if any)
Low
supports_vision: falseon custom text-only deploymentsFinal Attestation
Note
Medium Risk
Changes default router candidate selection on every request; behavior is well-tested but affects core load-balancing for vision vs text-only deployments.
Overview
Image requests in mixed model groups now avoid deployments explicitly marked text-only (
supports_vision: false) on every routing strategy, not only whenenable_pre_call_checksis enabled. Filtering moved out of_pre_call_checksinto_without_declared_text_only_deployments, which runs after cooldown/blocking/pre-call pruning and before order/strategy selection in both sync and async deployment pickers. If every leg is text-only, all candidates stay so provider errors still surface; when the vision leg is excluded by pre-call checks or cooldown, images can still route to a text-only deployment.Proxy error responses can expose the chosen deployment id more reliably via
maybe_get_model_id, which now falls back through a small_metadata_model_idhelper onlitellm_metadataand callermetadata(including in-place router updates), improvingx-litellm-model-idon failures such as chat completions.Reviewed by Cursor Bugbot for commit 891ae74. Bugbot is set up for automated code reviews on this repo. Configure here.