Repository navigation
fix: keep model capability flags out of provider requests - #46647
Conversation
A supports_* flag or another model map field set on a deployment's litellm_params was forwarded to the provider as a request field, so Bedrock answered 400 Extra inputs are not permitted on chat traffic and on the background health check alike. The shared owned-kwarg predicate now treats every ProviderSpecificModelInfo field as litellm-owned. Builds on the health-check-only approach in #40952 by leilei3167.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Automatic reviews are disabled for this repository. |
Merging this PR will not alter performance
|
|
@litereview code-review |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
✅ code-review5/5 · Ready for human reviewScope: full · Full PR review. No correctness findings. Checks and execution details
View review · Reviewed |
…arn when one sits in litellm_params
|
@litereview code-review |
| return inferred | ||
|
|
||
|
|
||
| def warn_on_ignored_model_capability_flags(model_name: str, litellm_params: Mapping[str, object]) -> str | None: |
There was a problem hiding this comment.
Medium · Startup warning tells admins to move supports_system_message to model_info, which disables it
- An admin sets
supports_system_message: falseunder a deployment'slitellm_params. This is a realLiteLLM_Paramsfield (litellm/types/litellm_params.py:268), and it appears inall_litellm_params. - The admin starts the proxy, and
Router._create_deploymentcallswarn_on_ignored_model_capability_flags. - That helper matches any key that starts with
supports_. So it logs:Deployment 'm' sets ['supports_system_message'] under litellm_params, where litellm ignores them ... Move them under model_info. - The warning is false.
completion()reads this key from its kwargs (litellm/main.py:5376) and uses it to rewrite system messages (main.py:5584-5589). - Suppose the admin follows the advice. Nothing reads
supports_system_messagefrommodel_info, so system messages go to the provider unchanged and models that reject them start failing.
Smallest fix: leave all_litellm_params members out of the warning, for example by adding and key not in all_litellm_params, or reuse is_model_capability_field only after that check.
Evidence
Code-derived, plus a local reproduction of the warning. Running Router(model_list=[{"model_name":"m","litellm_params":{"model":"openai/gpt-4o","api_key":"x","supports_system_message":False}}]) logged: LiteLLM Router:WARNING: common_utils.py:411 - Deployment 'm' sets ['supports_system_message'] under litellm_params, where litellm ignores them and never sends them to the provider. Move them under model_info for litellm to use them.
uv run python -c "from litellm.types.utils import all_litellm_params; print('supports_system_message' in all_litellm_params)" printed True. It is the only supports_ name in all_litellm_params.
litellm/main.py:5376: supports_system_message: Final = kwargs.get("supports_system_message", None), then map_system_message_pt(messages=messages) when it is False.
grep -rn supports_system_message litellm finds no reader that takes this key from model_info.
Latest summary by code-review · View this review · Reviewed c827a36e4ae5
There was a problem hiding this comment.
Fixed in f94ced7. The warning now skips declared litellm params like supports_system_message, and a router test covers that deployment
There was a problem hiding this comment.
Finding withdrawn
The reply is correct. In litellm/router_utils/common_utils.py:401-406, warn_on_ignored_model_capability_flags now warns only about keys that pass both is_model_capability_field(key) and key not in all_litellm_params. supports_system_message is a declared litellm param, so it no longer triggers the misleading "move it to model_info" advice. Both router call sites (router.py:9497 and router.py:10325) go through this helper. A new router test pins the behavior, and I confirmed it with a live Router run.
Evidence
litellm/router_utils/common_utils.py:401-406: if value is not None and is_model_capability_field(key) and key not in all_litellm_params
Local run on head: a deployment with supports_system_message: False and supports_vision: True logged a warning that listed only ['supports_vision'].
tests/unit/router_utils/test_router_utils_common_utils.py:865-875: the declared-litellm-param deployment with supports_system_message: False produces no capability warning (assert len(capability_warnings) == 1, and that one warning names only flag-in-litellm-params).
uv run pytest -q tests/unit/router_utils/test_router_utils_common_utils.py -k "capability or system_message" reported 2 passed.
GitHub does not allow this App to resolve this thread. A repository maintainer must do it manually.
Reviewed f94ced71aa70 · View follow-up
…ing and warn for runtime-added deployments
|
@litereview code-review |
…ts instead of every request
|
@litereview code-review |
… from the loaded catalog
|
@litereview code-review |
|
bugbot run |
…y_flags_reach_provider
…p load Cache the loaded catalog's field names when the cost map snapshot is taken so the capability-flag check stops walking every catalog entry per deployment, and add integration cells that drive the flagged and control deployments through chat, streaming, messages, responses, embeddings, health and model management against a vendor that rejects the flags
|
@litereview code-review |
|
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 2db878f. Configure here.
|
@litellm-stampbot |
litellm-stampbot: risk lowApproved at Rules (
Judge (gpt-6-luna): low, probability of high 0.12 (high at or above 0.90)
Pushes do not re-run this check. Comment |
kerry-berri
left a comment
There was a problem hiding this comment.
Low risk by rule and by judgement at 2db878f
Prerequisite for the BerriAI#47419 backport to stable/1.103.x, taken from the stable/1.104.x hand-port 49cacdb4b2. Minimal port of helpers from BerriAI#41523/BerriAI#43890/BerriAI#46647 needed by BerriAI#47419; behavior changes of those PRs not included. Registrations are tracked in a _runtime_registered_fields side table and cost-map entries stay plain dicts.
…I#47419 calls to stable/1.105.x Prerequisite for BerriAI#47419 on stable/1.105.x. Hand-ports from main (BerriAI#41523, BerriAI#46647): ModelInfoLookupMiss and lookup_model_info_for_registration, the flat-price override helpers (_without_overridden_price_variants and its rate-table helpers), and runtime_model_cost_registrations. runtime_model_cost_registrations reads the line's _runtime_registered_model_cost store instead of main's AliasedCostEntry.registered_fields, so cost-map alias entries stay plain dicts. Nothing on the line calls these until BerriAI#47419 lands, and register_model's behavior is unchanged.
TLDR
Problem this solves:
litellm_paramsreached the providerExtra inputs are not permittedfor it/healthand chat both failHow it solves it:
litellm_paramsmodel_infoUser Flow
Before: a proxy admin whose Bedrock Claude deployment carries a capability flag sees it fail on
/healthand on chatsupports_max_reasoning_effort: falseunder the deployment'slitellm_params, turns on background health checks, and starts the proxyunhealthy_endpointswith{"message":"supports_max_reasoning_effort: Extra inputs are not permitted"}After: the same deployment shows healthy and serves chat
supports_max_reasoning_effort: falseunder the deployment'slitellm_params, turns on background health checks, and starts the proxyhealthy_endpointsDesign decisions
No provider accepts a capability flag, so the router drops them from its own copy of each deployment, which chat, embeddings,
/v1/responsesand/healthread. Health probes drop them too, for the dashboard's Test Connect, whoselitellm_paramsskip the routerA capability flag is a
ProviderSpecificModelInfofield or asupports_key in the model map as loaded. A baresupports_prefix, or keys other deployments register, would drop real provider params like Replicate'ssupports_system_promptA flag sent in the request body still gets the provider's 400, as on main, since dropping it would hide a caller's mistake behind a 200
Admin views like
/model/infoshow the deployment as litellm serves it, without the flag, while the database row keeps it as saved. Copying flags intomodel_infowas rejected, since a dashboard edit would save the copy, which outlives its sourceRelevant issues
Refs #38941, which stays open for the reporter's retest
Replaces #40952 by @leilei3167, which found the leak but fixed only the health check
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 moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Both legs hit real Bedrock in us-west-2 through a proxy with 2 uvicorn workers, from the
config.yamlbelow or on Postgres for the dashboard and Test Connect cases. Before is the merge base958cba7016, after is the head2db878f915config.yaml (both legs)
/healthfalse/v1/responses/v1/messagestrue/healthHeadline case, User Flow step 2, raw before
Before:
After:
What the admin sees in the proxy console at startup, after only
The other 14 cases, each with its command and raw output
Chat, flag
false, User Flow step 3Before:
After:
Chat, streaming, flag
falseBefore:
After:
Chat, converse route, flag
falseBefore:
After:
/v1/responses, flagfalseBefore:
After:
/v1/messages, flagfalseBefore:
After:
Chat, flag
trueBefore:
After:
Chat,
bedrock_output_config_effort_ceiling: highBefore:
After:
Chat,
supports_forced_tool_use: trueBefore:
After:
Embeddings, Titan v2
Before:
After:
HTTP 200 with a 1024-float embedding and
"prompt_tokens":6. The raw 21 KB response is in after_2db878f915_embeddings.txtChat, control with no flag
Before:
After:
Dashboard model, chat
The proxy starts from this config with
DATABASE_URLset andSTORE_MODEL_IN_DB=True:Each leg adds the flagged model and a control model with no flag. Values the proxy encrypts are shown as
<encrypted>, and the after leg's response is the same shape:Both legs then poll
GET /v1/modelsuntil both models show on 8 calls in a row, so both workers have loaded them, and call chat twice.Before:
After:
Dashboard model,
/healthThe before error is cut to its first line here, and the raw response with its stack trace is in before_958cba7016_dashboard_health.txt
Before:
After:
Flag in request body, unchanged
The request goes to the control model, which has no flag in its
litellm_params.Before:
After:
Test Connect, flag
falseand no flagThe dashboard's Test Connect button on the Add Model page sends these requests, on the Postgres proxy after the dashboard cases. Test Connect takes a stored model with the same
modelstring as its base config, so on the base the request with no flag still sent the dashboard model's flag.Before:
After:
Observed during the run
/v1/messagesalready passed before, this PR leaves it/audit at
2db878f915PASS. The 36 cells in
tests/integration/routing/test_model_capability_flags.pyare red on the merge base wherever the flag reached the vendor, and green on both head runsMatrix, one row per cell
Each rig ran two-worker proxies with its own Postgres, Redis and a scripted vendor that rejects any flag with that vendor's own 400. Both head runs used the same seeds, and the 10 control cells in the same group passed on the head
958cba7016test_chat_completions_send_a_flagged_deployment_the_control_request[openai-static]test_streamed_chat_completions_send_a_flagged_deployment_the_control_request[openai]test_responses_send_a_flagged_deployment_the_control_requesttest_messages_send_a_flagged_deployment_the_control_request[openai]test_embeddings_send_a_flagged_deployment_the_control_requesttest_chat_completions_send_a_flagged_deployment_the_control_request[anthropic]test_messages_send_a_flagged_deployment_the_control_request[anthropic]test_chat_completions_send_a_flagged_deployment_the_control_request[bedrock_converse]test_streamed_chat_completions_send_a_flagged_deployment_the_control_request[converse]test_messages_send_a_flagged_deployment_the_control_request[converse]test_chat_completions_send_a_flagged_deployment_the_control_request[bedrock_invoke]test_chat_completions_send_a_flagged_deployment_the_control_request[openai-catalog_only]test_chat_completions_send_a_flagged_deployment_the_control_request[openai-ceiling]test_a_flagged_wildcard_deployment_sends_the_control_requesttest_health_probes_a_flagged_deployment_with_the_control_probetest_test_connection_probes_flagged_params_with_the_unflagged_probetest_any_flag_value_sends_the_control_request[int]test_any_flag_value_sends_the_control_request[list]test_any_flag_value_sends_the_control_request[empty_string]test_any_flag_value_sends_the_control_request[five_kb]test_any_flag_value_sends_the_control_request[null]test_any_flag_value_sends_the_control_request[false]test_a_flag_in_litellm_params_and_model_info_keeps_the_model_info_valuetest_an_undeclared_or_provider_supports_key_still_reaches_the_vendor[supports_litellm_qa_unknown]test_an_undeclared_or_provider_supports_key_still_reaches_the_vendor[supports_system_prompt]test_a_flagged_deployment_with_a_revoked_key_returns_the_vendor_401test_a_fallback_to_a_flagged_deployment_sends_the_control_requesttest_model_info_lists_the_served_params_without_the_flag[model_info]test_model_info_lists_the_served_params_without_the_flag[v2_model_info]test_model_group_info_reports_a_flagged_group_like_a_plain_onetest_supports_system_message_false_still_folds_the_system_prompttest_three_identical_requests_to_a_flagged_deployment_each_log_oncetest_a_flag_patched_onto_a_db_deployment_never_reaches_the_vendortest_updates_during_a_burst_never_send_the_flagtest_each_worker_and_a_replacement_send_config_and_db_flagged_deployments_without_the_flagtest_a_vendor_outage_between_bursts_reports_unhealthy_then_healthy_and_never_sends_the_flagType
🐛 Bug Fix
Caveats (if any)
Low
supports_max_reasoning_effortas a request field to Bedrock (400), for models withoutsupports_*_reasoning_effortin the model map #38941 did not reproduce, so it stays open/model/infono longer lists a flag stored underlitellm_params, by designFinal Attestation
The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
2db878f passes /audit
2db878f passes /live-pr-risk
Cursor Bugbot summary