← Back to DAGDA | Support | Source: https://github.com/BerriAI/litellm/pull/51005
Skip to content

fix(main): reject chat completions on decisions-only deployments - #51005

Open
shadowmodder wants to merge 11 commits into
BerriAI:mainfrom
shadowmodder:shadowmodder/fix/decisions-only-chat-rejection
Open

shadowmodder wants to merge 11 commits into
BerriAI:mainfrom
shadowmodder:shadowmodder/fix/decisions-only-chat-rejection

Conversation

@shadowmodder

@shadowmodder shadowmodder commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Part of #50876

TLDR

Problem: a hosted_vllm deployment with model_info.mode: decisions (Decision 3.0 / System One, serves /v1/systemone only) is accepted on /v1/chat/completions. LiteLLM forwards to upstream, vLLM has no such route, and the proxy returns an opaque litellm.NotFoundError: Hosted_vllmException - {"detail":"Not Found"}.

Fix: fail fast with a clear 400 before the upstream call when the target deployment's model_info.mode is decisions/evaluation.

Tests

  • 5 new tests in tests/unit/test_main.py (7 cases with parametrization): router guard tests over decisions and evaluation modes, sync and async; a no-router acompletion case; a chat-mode control that still serves; and a regression test that completion_with_fallbacks is called without caller_kwargs.
  • tests/unit/decisions/test_main.py is not changed by this PR. (An earlier commit deleted it by mistake while moving the tests out — restored in full; thanks @mmRoshani for catching it.)
  • litellm/main.py is ruff clean; the test additions introduce no new lint errors.

Caveats

  • ModelInfo-object model_info is not rejected (matches codebase behavior; the router passes a dict).
  • Catalog models are intentionally out of scope: a direct call naming a cost-map model whose mode is decisions/evaluation, without deployment model_info, is not rejected. The guard keys off the deployment's model_info, which is where the mode is configured for router/proxy use; a bare catalog name carries no deployment context.
  • Mixed-group deployments untested — the guard fires at attempt time.
  • Full type-check gate could not run locally (basedpyright needs 8GB heap, sandbox has 7.9GB) — needs CI.

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
@veria-ai

veria-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews


assert caught.value.status_code == 400
assert route.call_count == 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two things on the tests:

  • AGENTS.md says to extend the mapped test file for a bug fix. The change is in litellm/main.py, which maps to tests/unit/test_main.py; this file maps to litellm/decisions/main.py.
  • The guard also covers mode: "evaluation", but no test here uses it. Parametrizing the router test over both modes would cover it.

Comment thread litellm/main.py
else None
)
mode: object | None = info.get("mode") if info is not None else None
if not isinstance(mode, str) or not is_decisions_model_mode(mode):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This only looks at the deployment's model_info.mode. The Decisions code falls back to the catalog mode when the deployment has none (catalog_mode in litellm/llms/base_llm/decisions/transformation.py), and the cost map lists models with mode decisions or evaluation. Should a direct call to one of those without model_info also be rejected, or is that out of scope here?

Comment thread litellm/main.py Outdated
if model is None:
raise ValueError("model param not passed in.")
caller_kwargs: Final = cast("Mapping[str, object]", {**kwargs}) # cast-ok: completion takes untyped kwargs
_reject_decisions_only_chat_completion(model, caller_kwargs)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
_reject_decisions_only_chat_completion(model, caller_kwargs)
_reject_decisions_only_chat_completion(model, caller_kwargs.get("model_info"))

Comment thread litellm/main.py Outdated
Comment on lines +650 to +656
model_info: object | None = request_kwargs.get("model_info")
info: Mapping[str, object] | None = (
cast(Mapping[str, object], model_info) # cast-ok: isinstance narrows to a bare Mapping
if isinstance(model_info, Mapping)
else None
)
mode: object | None = info.get("mode") if info is not None else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These three assignments are not Final, so scripts/check_type_discipline.py litellm/main.py goes from 525 to 528 LIT010 findings, and AGENTS.md says a rule's count may not grow. as_str_mapping is already imported in this file and does the same narrowing without a cast:

Suggested change
model_info: object | None = request_kwargs.get("model_info")
info: Mapping[str, object] | None = (
cast(Mapping[str, object], model_info) # cast-ok: isinstance narrows to a bare Mapping
if isinstance(model_info, Mapping)
else None
)
mode: object | None = info.get("mode") if info is not None else None
info: Final = as_str_mapping(model_info)
mode: Final = None if info is None else info.get("mode")

Comment thread litellm/main.py Outdated
return response


def _reject_decisions_only_chat_completion(model: str, request_kwargs: Mapping[str, object]) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Taking model_info directly keeps the helper independent of the kwargs dict (goes with the other suggestions in this file).

Suggested change
def _reject_decisions_only_chat_completion(model: str, request_kwargs: Mapping[str, object]) -> None:
def _reject_decisions_only_chat_completion(model: str, model_info: object) -> None:

Comment thread litellm/main.py Outdated
### VALIDATE Request ###
if model is None:
raise ValueError("model param not passed in.")
caller_kwargs: Final = cast("Mapping[str, object]", {**kwargs}) # cast-ok: completion takes untyped kwargs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This new local ends up in args = _locals_snapshot(locals()) a few lines below, so it is passed on by completion_with_fallbacks(**args) and batch_completion_models(deployments=deployments, **args).

On this branch litellm.completion(model=..., messages=..., fallbacks=[...]) calls litellm.acompletion with an extra caller_kwargs={...} argument that holds a copy of every kwarg (including any credentials passed as kwargs and litellm_logging_obj). On main it does not. From reading add_provider_specific_params_to_optional_params, an unknown kwarg like this is copied into extra_body for OpenAI-SDK providers.

Reading model_info straight from kwargs avoids the new local:

Suggested change
caller_kwargs: Final = cast("Mapping[str, object]", {**kwargs}) # cast-ok: completion takes untyped kwargs
_reject_decisions_only_chat_completion(model, kwargs.get("model_info"))

@mmRoshani

Copy link
Copy Markdown

Thanks for picking this up. The guard does what the issue asks for the chat path: the router passes model_info as a dict, the call is rejected before any upstream request, and a 400 is not on the router's cooldown list while the old 404 is.

Requested changes are inline. The main one is the caller_kwargs local in completion(), which leaks into the sync fallback and batch paths.

A few things outside the diff:

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
…eview

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
@shadowmodder

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review, @mmRoshani — all six points are addressed in the latest commits (1a86a50, cfb6c5c):

  1. caller_kwargs leak: the caller_kwargs local is gone from completion() entirely. The guard now takes model_info directly (kwargs.get("model_info")), so nothing extra rides the locals snapshot into the sync fallback or batch paths. A new regression test asserts fallbacks receive no caller_kwargs.
  2. Type discipline: the guard's locals are now Final and it routes through as_str_mapping, which drops the three non-Final assignments you flagged — the LIT010 count does not grow.
  3. "Fixes" → "Part of [Bug]: hosted_vllm decisions-only models accepted on /chat/completions → opaque upstream 404 (mode: decisions / discoverable: false ignored for chat) #50876": done in the PR body above, since the dashboard picker and discoverable:false cases remain open.
  4. Tests: moved to tests/unit/test_main.py; both router tests are parametrized over decisions and evaluation modes.

Happy to adjust further if any of this still looks off.

@mmRoshani

Copy link
Copy Markdown

Thanks for the quick turnaround, @shadowmodder. I went through 1a86a50 and cfb6c5c.

Confirmed fixed

One blocker in cfb6c5c

That commit deletes all of tests/unit/decisions/test_main.py, not only the tests this PR added. At the merge-base (59a3e753) the file had 4,902 lines and 163 tests covering litellm/decisions/main.py, and it still exists on main. Only the 119 lines added in 725377b needed to move. Sorry if my earlier comment about the file mapping read as "remove the file".

This restores it, and the file then drops out of the PR's diff:

git checkout 59a3e753 -- tests/unit/decisions/test_main.py

Still open

  • My question about catalog models: the cost map has models with mode decisions or evaluation, and a direct call to one of those without model_info is not rejected. Is that intentionally out of scope? If so, a line in Caveats would be enough.

Also

  • The PR now shows merge conflicts with main. The deleted test file has changed on main since this branch was cut, so restoring it may clear this. If not, a merge or rebase on current main is needed.
  • The Tests section of the description still says the new tests are in tests/unit/decisions/test_main.py. They now live in tests/unit/test_main.py.

Optional

test_completion_with_fallbacks_does_not_receive_caller_kwargs only checks that one name is absent. Asserting that every forwarded key is a parameter of completion() would also catch any future stray local.

… mistake

Signed-off-by: Sudhir Vissa <sudhirvissa@gmail.com>
…s test

Signed-off-by: shadowmodder <sudhirvissa@gmail.com>
Signed-off-by: Sudhir Vissa <sudhirvissa@gmail.com>
…chat-rejection' into shadowmodder/fix/decisions-only-chat-rejection

Signed-off-by: Sudhir Vissa <sudhirvissa@gmail.com>
@shadowmodder

Copy link
Copy Markdown
Contributor Author

Thanks for the re-review, @mmRoshani — and for catching the test-file deletion. That one was my mistake: the commit that moved the tests out deleted all of tests/unit/decisions/test_main.py instead of only the tests this PR added.

Fixed now:

  • tests/unit/decisions/test_main.py is restored in full and no longer appears in this PR's diff. The branch is merged with current main and the merge conflict is cleared — the diff is back to litellm/main.py and tests/unit/test_main.py only.
  • Catalog models: intentional, and now stated in the Caveats. The guard keys off the deployment's model_info, which is where the mode is configured for router/proxy use; a direct call naming a catalog model without model_info carries no deployment context, so it is not rejected.
  • The Tests section of the description now points at tests/unit/test_main.py, where the tests live.
  • The fallback regression test asserts the fallback path is called once and that none of the forwarded kwargs is caller_kwargs.

The guard tests pass locally on the restored tree. Happy to adjust further if anything still looks off.

…hat reaches it

Signed-off-by: Sudhir Vissa <sudhirvissa@gmail.com>
@shadowmodder

Copy link
Copy Markdown
Contributor Author

Three follow-ups, @mmRoshani. 08c1d3b makes the 400 text route-neutral, since /v1/completions and /v1/responses reach the same guard. I left the stricter fallback assertion out because on current main completion() already forwards a requested_tool_choice local, so it fails for a reason outside this PR. And yes please on the live proxy run, thank you.

@mmRoshani

Copy link
Copy Markdown

Thanks @shadowmodder, I went through the latest commits up to 08c1d3b.

Confirmed

  • tests/unit/decisions/test_main.py is restored and matches main, so it is out of the PR's diff again.
  • The branch merges cleanly with current main.
  • completion() no longer forwards caller_kwargs to the fallback and batch paths.
  • The type-discipline and ruff counts for litellm/main.py match main.
  • The guard rejects decisions and evaluation deployments in both completion() and acompletion(), and lets chat deployments and calls without model_info through.
  • The reworded error fits /v1/completions and /v1/responses as well as chat.

How I checked

I reviewed the diff, ran the repo's lint scripts, and exercised the guard in isolation. I have not run the pytest suite locally, so I'm relying on CI for the new tests.

One correction from my side

Please ignore my optional suggestion about asserting that every forwarded key is a parameter of completion(). Main now has its own local (requested_tool_choice) before the snapshot, so that assertion would fail for reasons outside this PR. The current test is fine.

Still open

  • The catalog models question: a direct call to a cost-map model with mode decisions or evaluation and no model_info is not rejected. If that is out of scope, a line in Caveats is enough.

Once the required checks are green this looks good to me.

@shadowmodder

Copy link
Copy Markdown
Contributor Author

Thanks @mmRoshani — on catalog models: that is intentionally out of scope, and it is already stated in the Caveats section of the description (guard keys off deployment model_info; a bare catalog name carries no deployment context). Appreciate the re-review.

@shadowmodder

Copy link
Copy Markdown
Contributor Author

Merged main to clear the conflict in tests/unit/test_main.py. Main had added its own tests at the same spot, so both sets are kept and nothing in the fix itself changed.

This branch has not been deployed

No deployments
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.

2 participants