Skip to content

feat(router)!: apply each deployment's reasoning_effort_levels on every provider and route - #46601

Merged
mateo-berri merged 38 commits into
mainfrom
litellm_reasoning_effort_levels_every_route
Oct 20, 2026
Merged

mateo-berri merged 38 commits into
mainfrom
litellm_reasoning_effort_levels_every_route

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Breaking change: a non-numeric or true thinking.budget_tokens now answers 400, or drops under drop_params, and declared reasoning_effort_levels now round on every route, so check both before upgrading

TLDR

Problem this solves:

  • reasoning_effort_levels only worked on a few providers and routes
  • azure_ai rejected reasoning_effort even when declared
  • Undeclared levels reached the provider and failed with 400s

How it solves it:

  • One resolver rounds every effort and thinking budget onto declared levels
  • A declaration lets azure_ai take reasoning_effort, and remaps log at INFO

The 400 also covers undeclared deployments, and declared levels round up unless reasoning_effort_rounding is down

User Flow

Before: declared levels for Kimi K3 on Azure AI Foundry are ignored, and requests fail

  1. The admin adds reasoning_effort_levels: ["low", "high", "max", "none"] to an azure_ai/ and a hosted_vllm/ deployment's model_info
  2. POST https://litellm-domain/v1/chat/completions with "reasoning_effort": "medium" gets 400 azure_ai does not support parameters: ['reasoning_effort'], and hosted_vllm sends medium
  3. Claude Code with --effort medium answers, but the azure_ai model gets no effort
  4. POST https://litellm-domain/v1/responses with "reasoning": {"effort": "minimal"} gets 400 Unsupported value: 'minimal'

After: every route sends a declared level, and the proxy logs each change

  1. The admin adds the same declaration
  2. The same chat request returns 200 from both deployments, with high sent
  3. Claude Code answers, and high reaches the model
  4. The Responses request returns 200 with "effort": "low"

Decisions

Rounding up is the default, so a caller gets at least the level asked, or the strongest declared one

Only the deployment's own model_info counts, since the shared cost-map entry would round undeclared siblings. none and unknown strings pass through, and drop_params drops undeclared levels

A declaration counts as support, so azure_ai keeps a declared reasoning_effort under drop_params, which Claude Code turns on, and gpt-5 sends declared levels its row turns off

A thinking budget becomes an effort on a declaring deployment, by Claude's own mapping on adaptive Claude, unless chat passes thinking to a provider that reads it, like Gemini. A level that drop_params drops counts as never sent. Docs are in BerriAI/litellm-docs#2382

Edge cases

An explicit reasoning_effort or output_config.effort wins over a budget, default included, and goes out as reasoning_effort where the provider cannot read thinking

A reasoning_summary ask keeps the rounded effort, and adaptive Claude follows the caller's drop_params

A deployment declaring no levels, or only none, also drops a budget-derived effort under drop_params, so adaptive Claude gets adaptive thinking with no effort

Linear ticket

Resolves LIT-9492

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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 more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays 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

PASS at dc0b5ec. Declared levels now apply on every route and provider tested, and a malformed budget answers 400 instead of 500

Both legs ran 2-worker proxies on Postgres against real providers, recording what each provider got. Every case, Claude Code run and the rig are in this gist

Case Main (7b76b2b) This PR (dc0b5ec)
Chat, azure_ai, medium 400 high
Responses, hosted_vllm, minimal 400 low
Responses, azure_ai gpt-5.4 declaring xhigh 400 xhigh
String budget, chat, messages, Responses 500 400
Same, drop_params 500 no effort
Chat, Claude, budget true, false or null low 400
Claude Code, azure_ai, --effort medium no effort high
Claude Code, hosted_vllm, --effort xhigh high max

Before (7b76b2b)

Chat, azure_ai, medium

  1. python chat_client.py kimi-k3-azure-ai '{"reasoning_effort": "medium"}'
  2. The proxy answers 400 and the provider gets nothing
400 Error code: 400 - {'error': {'message': "litellm.UnsupportedParamsError: azure_ai does not support parameters: ['reasoning_effort'], for model=FW-Kimi-K3. To drop these, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\n. \n If you want to use these params dynamically send allowed_openai_params=['reasoning_effort'] in your request.\n\nLiteLLM: model group 'kimi-k3-azure-ai' failed with the error above. No fallback was attempted.", 'type': 'invalid_request_error', 'param': None, 'code': '400'}}
# what the provider received:
(nothing)

After (dc0b5ec)

Chat, azure_ai, medium

  1. The same command
  2. The proxy answers 200 and the provider gets high
200 finish_reason = stop
# what the provider received:
{"upstream": "foundry", "path": "/models/chat/completions", "status": 200, "model": "FW-Kimi-K3", "reasoning_effort": "high"}
All 137 cases

Each cell is what the provider received. Commands and outputs are in the gist, This PR and Main

Case Main (7b76b2b) This PR (dc0b5ec)
Chat, Bedrock Invoke Claude, output_config low beside budget 2048 with display updates low low
Chat, Bedrock Invoke Claude, budget 2048 with display updates (control) medium high
Chat, Claude, reasoning_effort none beside budget 2048, drop_params medium high
Chat, Claude, reasoning_effort HIGH beside budget 2048, drop_params 400 high
Chat, Bedrock Converse Claude, reasoning_effort none beside budget 2048, drop_params medium high
Chat, Bedrock Converse Claude, reasoning_effort HIGH beside budget 2048, drop_params 400 high
Chat, Claude, budget_tokens lots 500 400
Messages, Claude, budget_tokens lots 500 400
Responses, Claude, budget_tokens lots 500 400
Chat, Claude, budget_tokens lots, drop_params 500 adaptive, no effort
Messages, Claude, budget_tokens lots, drop_params 500 adaptive, no effort
Responses, Claude, budget_tokens lots, drop_params 500 adaptive, no effort
Chat, Claude, reasoning_effort default beside budget_tokens lots 400 400
Chat, Claude, reasoning_effort default beside budget_tokens lots, drop_params 400 adaptive, no effort
Chat, Bedrock Converse Claude, budget_tokens lots 500 400
Chat, Bedrock Converse Claude, reasoning_effort default beside budget_tokens lots 400 400
Chat, Claude with no declared levels, budget_tokens lots 500 400
Chat, azure_ai, output_config medium beside budget 2048 400 high
Chat, azure_ai, output_config low beside budget 2048 400 low
Messages, hosted_vllm, thinking budget 2048 medium high
Messages, azure_ai, thinking budget 2048 400 high
Messages, Claude declaring low and high, thinking budget 2048 medium high
Messages in the Claude Code shape, Bedrock Converse Claude declaring low and high, effort medium medium high
Chat with thinking, hosted_vllm in front of an engine that rejects minimal, budget 512 400 low
Chat with thinking, azure_ai, budget 2048 400 high
Chat with thinking, Claude declaring low and high, budget 2048 medium high
Chat with thinking, Claude declaring low and high, budget 2048, display omitted medium high
Chat with thinking and drop_params, hosted_vllm declaring only none, budget 2048 medium no effort
Chat with drop_params, hosted_vllm, an effort the deployment does not declare none no effort
Chat with drop_params, azure_ai, an effort the deployment does not declare no effort no effort
Chat with thinking, undeclared hosted_vllm, budget_tokens as the string 2048 500 400
Chat with thinking, hosted_vllm declaring levels, budget_tokens as the string 2048 500 400
Chat with reasoning_effort low and thinking, hosted_vllm declaring levels, budget_tokens as the string 2048 low low
Messages with budget_tokens as the string 2048, hosted_vllm declaring levels 500 400
Messages with budget_tokens as the string 2048, undeclared hosted_vllm 500 400
Messages with budget_tokens as the string 2048, Fireworks Kimi K3 500 400
Messages with budget_tokens as the string 2048, Gemini 3.8 Flash 500 400
Chat with thinking, undeclared hosted_vllm, budget_tokens true minimal 400
Chat with reasoning_effort low and thinking, undeclared hosted_vllm, budget_tokens true low low
Messages with budget_tokens true, Fireworks Kimi K3 low 400
Messages with budget_tokens as the string 2048 and drop_params, Fireworks Kimi K3 500 no effort
Messages with budget_tokens as the string 2048 and drop_params, Gemini 3.8 Flash 500 no effort
Chat with thinking and drop_params, hosted_vllm declaring levels, budget_tokens null 500 no effort
Messages with a thinking budget of 2048, Fireworks Kimi K3 (control) medium medium
Chat with reasoning_effort medium and a thinking budget of 2048, azure_ai declaring levels 400 high
Chat with reasoning_effort medium and a thinking budget of 2048, hosted_vllm declaring levels medium high
Chat, azure_ai, medium 400 high
Chat streaming, azure_ai, medium 400 high
Chat, azure_ai, xhigh 400 max
Responses, azure_ai, minimal 400 low
Responses, hosted_vllm, minimal 400 low
Responses, hosted_vllm, medium medium high
Responses, hosted_vllm rounding down per deployment, medium medium low
Chat, hosted_vllm in front of an engine that rejects minimal, minimal 400 low
Chat, hosted_vllm in front of an engine that rejects max, max 400 xhigh
Model group with both deployments, chat medium x4 medium high
Chat, azure_ai deployment with no declared levels, medium 400 400
Chat with thinking, undeclared hosted_vllm serving a Claude model name, budget 500 minimal minimal
Chat with thinking, undeclared hosted_vllm serving a Claude model name, budget 9000 high high
Chat with a thinking budget of 9000, Claude-named hosted_vllm declaring low, high, max high high
Messages with a thinking budget of 9000, Claude-named hosted_vllm declaring low, high, max high high
Responses, hosted_vllm, litellm_settings reasoning_effort_rounding down, medium medium low
Chat, Gemini declaring low and high, medium with a summary ask medium high
Chat, Gemini declaring low and high, medium with no summary ask medium high
Messages, Claude, budget 2048, an unknown thinking key, drop_params medium high
Messages, Claude, budget 2048, an unknown thinking key, no drop_params 400 400
Chat, Claude, reasoning_effort default beside budget 2048 400 adaptive, no effort
Chat, Claude, output_config effort default beside budget 2048 400 adaptive, no effort
Chat, Claude, output_config effort low beside budget 2048 low low
Messages, Claude, output_config effort default beside budget 2048 400 adaptive, no effort
Chat, azure_ai, output_config medium with no budget medium high
Messages, azure_ai, output_config medium beside budget 2048 400 high
Chat, hosted_vllm, output_config medium beside budget 2048 medium high
Chat, Claude, reasoning_effort HIGH beside budget 512, drop_params 400 low
Chat, azure_ai, output_config medium beside budget 2048, drop_params medium high
Chat, azure_ai, output_config default beside budget 2048 400 no effort
Chat, azure_ai, output_config default beside budget 2048, drop_params default no effort
Chat, azure_ai, output_config minimal beside budget 2048 400 low
Chat, azure_ai, output_config minimal beside budget 2048, drop_params minimal low
Chat, hosted_vllm, output_config medium beside budget 2048, drop_params medium high
Chat, hosted_vllm, output_config default beside budget 2048 medium no effort
Chat, hosted_vllm, output_config default beside budget 2048, drop_params medium no effort
Chat, hosted_vllm, output_config minimal beside budget 2048 medium low
Chat, hosted_vllm, output_config minimal beside budget 2048, drop_params medium low
Chat, Bedrock Converse Claude declaring low and high, budget 2048 medium high
Chat, Bedrock Converse Claude declaring low and high, json_schema beside budget 2048 medium high
Chat, Bedrock Invoke Claude declaring low and high, json_schema beside budget 2048 medium high
Chat, Bedrock Converse Claude whose model_info opts out of native structured output, json_schema beside budget 2048 medium high
Chat, Claude declaring low and high, json_schema beside budget 2048 medium high
Chat, OpenRouter Claude declaring low and high, budget 2048 budget 2048 high
Chat, OpenRouter Claude declaring low and high, reasoning_effort default beside budget 2048 400 adaptive, no effort
/v1/messages, Claude declaring low and high, effort turbo beside budget 2048, drop_params 400 high
/v1/messages, Claude declaring low and high, effort none beside budget 2048, drop_params 400 high
/v1/messages, Claude declaring low and high, effort default beside budget 2048, drop_params 400 adaptive, no effort
/v1/messages, Claude declaring low and high, budget 2048, drop_params (control) medium high
Chat, Claude declaring low and high, budget "lots", drop_params only in litellm_settings 500 adaptive, no effort
Chat, Claude with no declared levels, budget "lots", drop_params only in litellm_settings 500 adaptive, no effort
/v1/messages, Claude declaring low and high, budget "lots", drop_params only in litellm_settings 500 adaptive, no effort
/v1/messages, Claude with no declared levels, budget "lots", drop_params only in litellm_settings 500 adaptive, no effort
Chat, Claude with no declared levels, budget "lots", no drop_params (control) 500 400
Chat, gpt-5.6 declaring low and high, function tools and effort medium (bridged to Responses) medium high
/v1/messages, gpt-5.6 declaring low and high, thinking budget 2048 medium high
/v1/messages, gpt-5.6 declaring low and high, budget "lots", drop_params low no effort
Chat, gpt-5.3-codex declaring low and xhigh, effort xhigh xhigh xhigh
Chat, gpt-5.3-codex declaring low and xhigh, effort high (rounds up to xhigh) high xhigh
Chat, azure_ai gpt-5.4 deployment declaring low/high/xhigh, reasoning_effort xhigh 400 xhigh
Chat, azure_ai gpt-5.4 deployment declaring low/high/xhigh, reasoning_effort medium medium high
Chat, native Claude Sonnet 5.5, thinking budget_tokens true low 400
Chat, native Claude Sonnet 5.5, thinking budget_tokens true, global drop_params low adaptive, no effort
/v1/messages, native Claude Sonnet 5.5, thinking budget_tokens true low 400
/v1/messages, native Claude Sonnet 5.5, thinking budget_tokens true, drop_params true low adaptive, no effort
Responses, gpt-5.3-codex declaring low and xhigh, effort xhigh xhigh xhigh
Responses, gpt-5.3-codex declaring low and xhigh, effort high (rounds up to xhigh) high xhigh
Responses, azure_ai gpt-5.4 deployment declaring low/high/xhigh, effort xhigh 400 xhigh
Chat, Claude declaring no levels, budget 2048 under drop_params medium adaptive, no effort
Chat, Claude declaring only none, budget 2048 under drop_params medium adaptive, no effort
Chat, Bedrock Converse Claude declaring no levels, budget 2048 under drop_params medium adaptive, no effort
Chat, Claude declaring no levels, budget 2048 without drop_params medium medium
Messages, Claude declaring no levels, budget 2048 under drop_params medium adaptive, no effort
Messages, Claude declaring only none, budget 2048 under drop_params medium adaptive, no effort
Messages, Bedrock Converse Claude declaring no levels, budget 2048 under drop_params medium adaptive, no effort
Messages, Claude declaring no levels, budget 2048 without drop_params medium medium
Chat, azure_ai Kimi declaring no levels, budget 2048 under drop_params no effort no effort
Chat, azure_ai Kimi declaring no levels, budget 2048 without drop_params 400 400
Messages, azure_ai Kimi declaring no levels, budget 2048 under drop_params no effort no effort
Messages, Bedrock Invoke Claude declaring no levels, budget 2048 under drop_params medium adaptive, no effort
Chat, native Claude Sonnet 5.5, thinking budget_tokens false low 400
/v1/messages, native Claude Sonnet 5.5, thinking budget_tokens false low 400
Chat, native Claude Sonnet 5.5, thinking budget_tokens null low 400
/v1/messages, native Claude Sonnet 5.5, thinking budget_tokens null low 400
Chat, native Claude Sonnet 5.5, thinking budget_tokens "" low 400
/v1/messages, native Claude Sonnet 5.5, thinking budget_tokens "" low 400
Responses, native Claude Sonnet 5.5, thinking budget_tokens false low 400
/v1/messages, native Claude Sonnet 5.5, thinking budget_tokens null, drop_params true low adaptive, no effort
Chat, native Claude Sonnet 5.5, thinking budget_tokens false, global drop_params low adaptive, no effort
Chat, Bedrock Converse Claude, thinking budget_tokens false low 400
/v1/messages, Bedrock Invoke Claude, thinking budget_tokens null low 400
Claude Code TUI, both legs

Each run starts the real Claude Code TUI with ANTHROPIC_BASE_URL on the proxy, runs claude --model <deployment> --effort <level>, then types Reply with the single word ok. Pane text and provider lines are in the gist

azure_ai Kimi K3, --effort medium

Main sends no effort, and this PR sends high

This PR (dc0b5ec)

pr46601-dc0b5ec510-head-tui-azmedium.png

Main (7b76b2b)

pr46601-3297662b9e-base-tui-azmedium.png

Bedrock Converse Claude declaring low and high, --effort medium

Main sends medium, and this PR sends high

This PR (dc0b5ec)

pr46601-dc0b5ec510-head-tui-converse.png

Main (7b76b2b)

pr46601-3297662b9e-base-tui-converse.png

Anthropic Claude declaring low and high, --effort medium

Main sends medium, and this PR sends high

This PR (dc0b5ec)

pr46601-dc0b5ec510-head-tui-native.png

Main (7b76b2b)

pr46601-3297662b9e-base-tui-native.png

hosted_vllm Kimi K3, --effort xhigh

Main sends high, and this PR sends max

This PR (dc0b5ec)

pr46601-dc0b5ec510-head-tui-xhigh.png

Main (7b76b2b)

pr46601-3297662b9e-base-tui-xhigh.png

Surprises

  • output_config alone reaches azure_ai chat unread, as on main

Type

🆕 New Feature

Caveats (if any)

Medium

  • Existing declarations now round up everywhere, as the customer agreed
  • A backend rejecting a declared level answers 400, even under drop_params, on azure_ai and gpt-5
  • Cost-map levels alone round nothing, so an undeclared azure_ai/FW-Kimi-K3 deployment advertises levels it still 400s on
  • Undeclared deployments keep the old /v1/messages round-down
  • Mistral and together_ai still re-round against the shared cost-map entry, as on main
  • The remap line only shows with LITELLM_LOG=INFO

Low

  • Effort strings match case-sensitively, so HIGH goes out as sent, as on main
  • default still reaches an undeclared deployment as sent, as on main
  • azure_ai declaring no levels still 400s on a budget without drop_params, now naming reasoning_effort
  • WebSocket Responses to openai and azure, and the Rust bridge's /v1/messages, skip declared levels, as on main
  • bedrock_mantle and sail Responses still refuse declared levels their row turns off, as on main

Blast radius

/live-pr-risk at dc0b5ec against 7b76b2b, with recorders in front of every provider

Every cell's command, both legs' answers, and the wire each provider got are in the gist

Breaking

None. Nothing answers differently from main beyond the approved changes below. Main's gpt-5 effort check from #43935, which merged since the last run, now lets a declared level through on Responses and on chat bridged to Responses (rk50-rk52), and a level the row allows goes out the same on both sides (rk56). The other main changes this PR crosses (the Bedrock native output retry, the native Databricks /v1/messages route, and the Rust bridge catalog) behave the same on both sides except where a deployment declares levels

Backward incompatible

  • A boolean budget_tokens that answered 200 on main now answers litellm's 400, or drops under drop_params, on hosted_vllm, mistral, and on /v1/messages to gemini, fireworks, and openrouter, and from litellm.adapter_completion, aadapter_completion, and Router.aadapter_completion (J3). Approved by Mateo's drop_params ruling of 2026-10-02 and the round 2 ruling that a malformed budget answers 400 or drops
  • A string or null budget that answered 500 on main now answers the same 400 or drops (rk04, rk05, rk10-rk15, rk22, J1, J2, J5, J6, J8). Same approval
  • On adaptive Claude a false, null, or empty string budget sent low on main and now answers 400, or drops under drop_params, on chat, /v1/messages, Responses, Bedrock Converse, and Bedrock Invoke (the proof's budget rows). Same approval
  • /v1/messages bridged to the Responses API on openai sent reasoning.effort: low for a malformed budget on main and now answers 400 or drops reasoning. Same approval
  • Existing declarations round up (medium to high in rk02, rk06, rk20, rk21, rk31, rk33, rk41, rk42), as caveat 1 says and the customer agreed on the ticket
  • A declared level now reaches azure_ai, and openai or azure gpt-5 on chat and Responses, even under drop_params, where main refused or dropped it (rk50-rk52). A backend that rejects it answers its own 400, as caveat 2 says and the ticket asks
  • An explicit effort beside a thinking budget on a provider that cannot read thinking now sends the effort and no thinking where main answered 400, per the round 2 ruling that an explicit effort wins
  • A deployment declaring no levels, or only none, now drops a budget-derived effort under drop_params, so adaptive Claude gets adaptive thinking with no effort where main sent medium (the empty-declaration rows in the proof). Same drop_params approval
  • azure_ai declaring no levels without drop_params still answers 400 for a thinking budget, now naming reasoning_effort instead of thinking. Low caveat
  • AnthropicAdapter.translate_completion_input_params reads drop_params from the request or litellm.drop_params and raises for a malformed budget without it. The other translation helpers keep dropping it by default

Regression risk

  • The Bedrock native output retry from main re-sends through the same mapping that carries the rounded effort, read in the code. No live call reached it: Bedrock accepted every schema litellm sent natively. No unit test asserts the retry's effort
  • Providers whose Responses config overrides map_openai_params (xai, azure o-series, github_copilot, volcengine, bedrock_mantle, sail) keep main's check, read in the code and live for bedrock_mantle only

Dependency graph

Dependent Status
Fallback to an undeclared deployment live rk01, rk03
Fallback to a declared deployment live rk02, rk06
Fallback after a malformed budget live rk04, rk05
Cooldown after six 400s live rk10-rk17, none
Bedrock native output live rk20, rk21
Bedrock native output retry code-read
gpt-5 check, Responses live rk50, rk56
gpt-5 check, chat bridged to Responses live rk51, rk52
Responses compact live rk53, same as main
bedrock_mantle Responses live rk54, rk55, Low caveat
sail and other overrides code-read, as on main
Databricks Claude, both endpoints live rk40-rk42
Mistral declared level live rk30
HTTP Responses, openai live rk31
WebSocket Responses, hosted_vllm live rk33
WebSocket Responses, openai live rk32, Low caveat
Rust bridge /v1/messages live rk34 at 7d4cd14, unchanged since
SDK adapters live J1-J8
Empty or none-only declarations live, proof rows
false or null budget, adaptive Claude live, proof rows
Integration suite live at 3297662, no new reds
Merge with main 1660c8b live, 126 cases same as a25ec8f

Not verified

  • The Bedrock native output retry above
  • sail, xai, github_copilot, and volcengine Responses with declared levels, read in the code only
  • Vertex AI Claude with declared levels, which has no cell here or in the integration suite
  • A false or null budget on Databricks and Vertex AI Claude, which share the helper the proof's budget rows reach
  • The MCP auto-execute loop, which calls the Responses API again for each tool round
  • The proxy's custom adapter pass-through endpoint, which answers 500 No matching adapter given on main and on this PR before the adapter runs
  • Logging destinations and the Admin UI
Audit round 3 of 3 at d4cf71e against f6ae259

All 222 integration cells pass on two head runs, the base fails the 173 cells this PR changes, as predicted, and all 378 controls from main's neighboring reasoning and thinking tests pass on the head. The full matrix is in this gist. Round 3 found no open rows, and its approved behavior changes are these

  1. A budget_tokens: true that answered 200 now answers 400 naming the budget
  2. An explicit effort beside thinking on a declaring azure_ai deployment sends the effort and no thinking
  3. /v1/messages to openai with a string budget answers 400 naming the budget
  4. On a declaring adaptive Claude deployment, default beside a budget now sends adaptive thinking with no effort, and a level that drop_params drops counts as never sent
  5. A non-numeric string budget on adaptive Claude answers 400 instead of 500, or adaptive thinking with no effort under drop_params
  6. An output_config.effort beside a budget on a declaring azure_ai or hosted_vllm deployment also goes out as reasoning_effort

Final 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
Bugbot summary

[!NOTE]
High Risk
This is a breaking behavior change across core routing (completion, Responses, Anthropic bridges) that alters which effort reaches upstream providers and when malformed thinking budgets fail vs drop.

Overview
Breaking: non-numeric or boolean thinking.budget_tokens now returns 400 (or is dropped when drop_params is on) instead of coercing or 500ing.

Deployments that declare reasoning_effort_levels in their own model_info now get a single resolver on chat completions, Responses, and native /v1/messages: requested reasoning_effort, output_config.effort, and thinking budgets are rounded onto declared tiers (default reasoning_effort_rounding: up, overridable per deployment or globally). Remaps are logged at INFO. Only the deployment’s declaration counts—not the shared model cost map—so siblings stay unchanged.

azure_ai and GPT-5 paths treat a declaration as support: declared levels can pass even when the model map would reject or drop them; undeclared levels still follow existing provider checks. Anthropic adaptive thinking translation and pass-through adapters thread drop_params through budget→effort mapping. normalize_reasoning_effort_value skips the old degradation chain when the deployment owns rounding.

Reviewed by Cursor Bugbot for commit dc0b5ec. Bugbot is set up for automated code reviews on this repo. Configure here.

…y provider and route

A deployment's declared reasoning_effort_levels now decide the effort sent upstream on /v1/chat/completions, /v1/messages and /v1/responses for every provider. Requests round up by default, litellm.reasoning_effort_rounding and model_info.reasoning_effort_rounding switch to down, a declaration lets providers like azure_ai accept reasoning_effort, and each remap logs one INFO line with structured fields.
@devin-ai-integration

devin-ai-integration Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@codspeed

codspeed Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 32 untouched benchmarks


Comparing litellm_reasoning_effort_levels_every_route (dc0b5ec) with main (d56ff28)

Open in CodSpeed

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.56631% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...itellm/router_utils/reasoning_effort_capability.py 97.57% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

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.

Stale Bugbot comment from a previous run.

…ed levels

Cost map levels no longer round requests or force-allow reasoning_effort, so undeclared sibling deployments and catalog-only models behave as on main. A declaring deployment lets azure_ai accept any level the resolver sends, and a hosted_vllm chat thinking budget is rounded too.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

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.

Stale Bugbot comment from a previous run.

…ound native /v1/messages effort

Under drop_params a level outside the deployment's reasoning_effort_levels is
dropped instead of sent. Providers that take /v1/messages natively now round
output_config.effort onto the deployment's declaration. The rounding setting
ignores case and surrounding spaces.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

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.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@cursor cursor Bot left a comment •

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.

Stale Bugbot comment from a previous run.

@litereview

litereview Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

No correctness findings.

I reviewed the full PR at dc0b5ec510, including the last commit, which rejects a null, false or "" thinking.budget_tokens on adaptive Claude. The 223 cells in the PR's integration suite pass on this head. The touched unit suites also pass, and a live proxy check reproduced the main routing and rejection behavior. I rechecked both earlier findings, and neither has come back.

Checks and execution details
  • Passed · Real testing evidence (required): In scope because the PR changes translation in litellm/llms/anthropic/common_utils.py, the anthropic pass-through adapters, hosted_vllm, azure_ai, the gpt-5 chat config and the OpenAI Responses config.

  • Integration suite. On this head I ran tests/integration/run.py providers tests/integration/routing/test_reasoning_effort_levels_wire.py tests/integration/routing/test_reasoning_effort_levels_chaos.py --workers 2, which starts a real proxy on Postgres and Redis with a scripted upstream. Result: 223 passed in 265.10s. The cells assert the body that reaches the upstream across chat, /v1/messages and Responses on azure_ai, hosted_vllm, anthropic, bedrock converse and invoke, gemini, openrouter and fireworks. They cover rounding up and down, drop_params, default, none, thinking budgets, display: omitted, and bool, null, list, empty and word budgets. They also cover fallback, model groups, and a worker kill or restart.

  • Fixture provenance. The cells check outbound requests. The scripted replies only end each exchange, and the gist 3f570e1a68b803b05a6698bd92a2d9f9 has before and after runs against real providers at a25ec8f02b, with the rig config included.

  • Last commit. The PR's evidence does not reach dc0b5ec, which removes or 0 for adaptive Claude. I checked it live myself. A proxy on this head with an anthropic stub at 127.0.0.1:8199 returned UnsupportedParamsError: thinking.budget_tokens must be a number, got NoneType for budget_tokens: null, on both the declared and the undeclared claude-opus-5-5 group. The parametrized unit test _NON_NUMERIC_BUDGETS (True, False, None, "", "lots", [4096]) covers the reject path and the drop_params path.

  • Unit suites. I ran the touched suites (test_reasoning_effort_capability, test_anthropic_common_utils, the adapters transformation and handler normalization tests, test_anthropic_messages_router, test_responses_api_request_body): 906 passed.

  • Passed · Compatibility notice (required): Two real incompatibilities exist, and the PR gives notice for both.

  1. A non-numeric thinking.budget_tokens used to fail differently or succeed. true sent low or minimal. null, false and "" on adaptive Claude became budget 0 through or 0 and got effort: low. On this head these answer 400, and under drop_params they send adaptive thinking with no effort. I confirmed the null case live on the proxy.
  2. A deployment that declares reasoning_effort_levels now gets its levels rounded on every route. For example, medium on a deployment declaring ["low","high"] now sends high.

The title feat(router)!: carries the breaking marker. The description's first line names both behaviors and tells operators to check them before upgrading. The drop_params migration is spelled out, as is reasoning_effort_rounding: down.

  • Passed · Changed behavior and result consistency (required): - Standards read. Root AGENTS.md and tests/integration/AGENTS.md. Integration tests must assert the outbound body, and new integration files first run on main. No added code comments violate the comment rule; only cast-ok suppressions were added.
  • Chat path traced. completion() passes the reasoning fields through resolve_chat_reasoning, then get_optional_params, then the provider map_openai_params. reasoning_effort_needs_allowing adds the effort to allowed_openai_params for azure_ai.
  • Responses path traced. responses() calls resolve_deployment_reasoning_effort, then _provider_mapped_params, which falls through to map_openai_params_for_deployment only when the base class method is not overridden.
  • /v1/messages path traced. The adapter handler sends deployment_model_info into normalize_reasoning_effort_value, which skips degradation when the deployment declares levels that round.
  • Boundary cases. Absent, null, false, "" and word budgets. Explicit effort versus a budget, including default and an effort that drop_params drops. Empty and none-only declarations. Global versus per-request drop_params. Per-deployment versus global rounding. Integration cells or my live proxy run exercised each of these.
  • Live proxy, outbound body. An undeclared Claude deployment sent display: omitted with effort: medium. A declaring deployment sent display: omitted with effort: high. /v1/messages with output_config set to medium sent high, and minimal sent low.
  • CI. Many required jobs on GitHub were still in_progress when I checked. My local runs above are the execution evidence.

View review · Reviewed dc0b5ec510ab

Comment thread litellm/main.py Outdated
api_base=api_base,
)
routing_kwargs: Final = cast("Mapping[str, object]", kwargs) # cast-ok: kwargs is the untyped request dict
deployment_reasoning_effort: Final = resolve_deployment_reasoning_effort(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · hosted_vllm sends an effort from thinking after drop_params dropped it

  1. A hosted_vllm/ deployment declares reasoning_effort_levels: ["none"] (or []), and drop_params is on.
  2. A caller sends thinking: {"type": "enabled", "budget_tokens": 2048} and no reasoning_effort, which is what /v1/messages clients such as Claude Code do.
  3. completion() turns thinking into medium, and resolve_deployment_reasoning_effort drops it because the deployment does not declare medium. That leaves resolved_reasoning_effort = None.
  4. thinking still goes into get_optional_params. HostedVLLMChatConfig.map_openai_params then sees no reasoning_effort, derives medium from thinking again, and sends it upstream. A plain reasoning_effort="medium" request to the same deployment is dropped, as the PR describes.

The smallest fix is to also strip thinking from the hosted_vllm params whenever the resolver changed or dropped the effort it derived from thinking.

Evidence

Local reproducer (respx stub of the vLLM endpoint; it checks the outbound body only, not a real upstream response):

completion(model="hosted_vllm/my-kimi", api_base=B, api_key="k", messages=[...],
    thinking={"type":"enabled","budget_tokens":2048}, drop_params=True,
    model_info={"id":"d1","reasoning_effort_levels":levels})

Output:

['none'] medium
[] medium
['low', 'high'] high
reasoning_effort=medium, ['none'] None

litellm/main.py ~5490 passes reasoning_effort_from_thinking(thinking) into the resolver but still forwards the original thinking ("thinking": thinking in optional_param_args).

litellm/llms/hosted_vllm/chat/transformation.py ~98: thinking_effort = reasoning_effort_from_thinking(non_default_params.pop("thinking", None)); if thinking_effort is not None and "reasoning_effort" not in non_default_params: ... re-derives the dropped level.

Latest summary by code-review · View this review · Reviewed 680a4ec7ddb8

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bc933eb. A thinking-derived effort now goes through drop_params, and thinking is no longer forwarded, so nothing reaches the engine

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Finding withdrawn

The reply is correct. In litellm/main.py, completion() now always computes thinking_effort for hosted_vllm and sends it through resolve_deployment_reasoning_effort, which applies drop_params. When thinking_effort is set, completion() forwards "thinking": None. HostedVLLMChatConfig.map_openai_params therefore never sees thinking and cannot derive the dropped level again. A local run confirms the outbound body has no reasoning_effort and no thinking for deployments declaring ["none"] or [].

Evidence

litellm/main.py ~5491-5499: thinking_effort = thinking_budget_effort(...) if reasoning_effort is None and thinking is not None and (custom_llm_provider == "hosted_vllm" or deployment_rounds_reasoning_effort(...))

litellm/main.py ~5501-5510: the resolver receives reasoning_effort if reasoning_effort is not None else thinking_effort along with the drop_params setting

litellm/main.py ~5647: "thinking": thinking if thinking_effort is None else None

litellm/llms/hosted_vllm/chat/transformation.py ~98: the code that derives an effort from thinking gets None and does nothing

Local respx run at head (outbound body only): ['none'] None False, [] None False, ['low','high'] high False

GitHub does not allow this App to resolve this thread. A repository maintainer must do it manually.

Reviewed bc933ebf12c7 · View follow-up

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@cursor cursor Bot left a comment •

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.

Stale Bugbot comment from a previous run.

Comment thread litellm/main.py Outdated
api_base=api_base,
)
routing_kwargs: Final = cast("Mapping[str, object]", kwargs) # cast-ok: kwargs is the untyped request dict
thinking_effort: Final = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Low · Chat requests to declaring Claude deployments lose thinking.display: omitted

  1. An anthropic/claude-opus-5-5 deployment (adaptive thinking) declares reasoning_effort_levels: ["low", "high"] in its model_info.
  2. A caller sends a chat completion with thinking: {"type": "enabled", "budget_tokens": 2048, "display": "omitted"} and no reasoning_effort.
  3. Because the deployment declares levels, completion() turns thinking into thinking_effort (medium, rounded up to high). It then forwards "thinking": None, so it throws away the caller's whole thinking object.
  4. AnthropicConfig.map_openai_params sees only reasoning_effort=high. _map_reasoning_effort builds thinking: {"type": "adaptive", "display": "summarized"}, so Anthropic gets summarized instead of omitted, and the caller receives thinking text it asked to hide. Before this PR, and on deployments that declare nothing, translate_legacy_thinking_for_adaptive_model keeps display.

Smallest fix: when thinking_effort comes from an adaptive Claude translation, keep the translated thinking (with its display) and replace only the effort, instead of nulling thinking. The native /v1/messages path already does this through with_adaptive_thinking_as_effort.

Evidence

Local reproducer at head bc933eb. A respx stub stands in for api.anthropic.com, and the script checks only the outbound body:

litellm.completion(model="anthropic/claude-opus-5-5", api_key="k", messages=[...], max_tokens=4096,
    thinking={"type":"enabled","budget_tokens":2048,"display":"omitted"}, **({"model_info": mi} if mi else {}))

Output (levels, sent thinking, sent output_config):

None {'type': 'adaptive', 'display': 'omitted'} {'effort': 'medium'}
['low', 'high'] {'type': 'adaptive', 'display': 'summarized'} {'effort': 'high'}

litellm/main.py ~5647: "thinking": thinking if thinking_effort is None else None

litellm/llms/anthropic/chat/transformation.py ~1386-1391: on adaptive models _map_reasoning_effort always returns AnthropicThinkingParam(type="adaptive", display="summarized")

litellm/llms/anthropic/common_utils.py ~947-951: translate_legacy_thinking_for_adaptive_model keeps display in ("summarized", "omitted"). Nothing calls it on this path once thinking is nulled.

Latest summary by code-review · View this review · Reviewed bc933ebf12c7

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed live, display omitted goes out as summarized. Keeping it as a Low caveat in the body, since only the returned thinking text changes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Finding still applies

Thanks for checking this live. Your result confirms the finding: on a deployment that declares reasoning_effort_levels, a caller's thinking.display: "omitted" goes out as "summarized", and the caller gets back thinking text it asked to hide. Listing it as a known caveat in the PR description doesn't fix it, and the code at head hasn't changed. The finding stays at Low severity. The smallest fix is still to keep the translated adaptive thinking (with its display) and replace only the effort. The native /v1/messages path already does this through with_adaptive_thinking_as_effort.

Evidence

Author reply: "Confirmed live, display omitted goes out as summarized. Keeping it as a Low caveat in the body".

litellm/main.py:5647 at head bc933ebf12 still reads "thinking": thinking if thinking_effort is None else None, (thinking_effort is defined at line 5491).

litellm/llms/anthropic/chat/transformation.py:1391 still hardcodes display="summarized" in _map_reasoning_effort for adaptive models.

Reviewed bc933ebf12c7 · View follow-up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 92183fa. Chat now keeps the caller's thinking, display included, and replaces only the effort, on anthropic, bedrock, and azure_ai Claude

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Finding withdrawn

Thanks for the fix. I checked it at head 92183fa820 and it holds. completion() no longer sets thinking to None when it derives thinking_effort. It now passes the caller's thinking through adaptive_thinking_beside_effort, which returns the original object whenever the model takes adaptive translation. AnthropicConfig.map_openai_params then runs translate_legacy_thinking_for_adaptive_model, which keeps display, and the rounded effort lands in output_config.

A local reproducer confirms this on anthropic and azure_ai Claude. A deployment declaring ["low", "high"] now sends {'type': 'adaptive', 'display': 'omitted'} with effort: high. Before the fix it sent display: summarized. I did not run a bedrock reproducer, but bedrock goes through the same main.py change.

Evidence

litellm/main.py ~5648: "thinking": (thinking if thinking_effort is None else adaptive_thinking_beside_effort(thinking, resolved_reasoning_effort, model=model, custom_llm_provider=custom_llm_provider))

litellm/router_utils/reasoning_effort_capability.py adaptive_thinking_beside_effort: returns the caller's thinking when with_adaptive_thinking_as_effort produces output_config. It returns None only when the effort is None or none, or when the model is not adaptive.

Local reproducer (uv run, a respx stub stands in for the provider, and the script checks only the outbound body). Each call used thinking={"type":"enabled","budget_tokens":2048,"display":"omitted"}:

anthropic/claude-opus-5-5 None {'type': 'adaptive', 'display': 'omitted'} {'effort': 'medium'}
anthropic/claude-opus-5-5 {'reasoning_effort_levels': ['low', 'high']} {'type': 'adaptive', 'display': 'omitted'} {'effort': 'high'}
anthropic/claude-opus-4-7 {'reasoning_effort_levels': ['low', 'high']} {'type': 'adaptive', 'display': 'omitted'} {'effort': 'high'}
azure_ai/claude-opus-4-7 {'reasoning_effort_levels': ['low', 'high']} {'type': 'adaptive', 'display': 'omitted'} {'effort': 'high'}

Non-adaptive anthropic/claude-sonnet-4-6 with levels declared sends the original {'type':'enabled','budget_tokens':2048,'display':'omitted'}, the same as without levels, so nothing regressed there.

GitHub does not allow this App to resolve this thread. A repository maintainer must do it manually.

Reviewed 92183fa8207f · View follow-up

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

…ing budget on adaptive Claude

Warn on a reasoning_effort_rounding value other than up or down instead of silently rounding up
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…ing no ranked levels excludes

A deployment declaring [] or ["none"] skipped the budget check, so adaptive Claude
still sent the budget-derived output_config.effort under drop_params on chat,
Bedrock Converse, and native /v1/messages. The adaptive thinking now goes out
without that effort
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…ort_levels_every_route

# Conflicts:
#	litellm/llms/anthropic/pass_through/messages/handler.py
#	litellm/main.py
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread litellm/llms/anthropic/common_utils.py Resolved
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

1 similar comment
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@litereview

litereview Bot commented Oct 20, 2026

Copy link
Copy Markdown

Review already requested

code-review is already reviewing dc0b5ec510ab. View existing review.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

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.

✅ 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 dc0b5ec. Configure here.

@mateo-berri
mateo-berri merged commit 96f1bc0 into main Oct 20, 2026
103 checks passed
@mateo-berri
mateo-berri deleted the litellm_reasoning_effort_levels_every_route branch October 20, 2026 04:34
mateo-berri added a commit that referenced this pull request Oct 20, 2026
…control

Resolves the conflicts with #46411 and #46601. A prompt_cache_breakpoint on a
tool now marks a tool boundary and is stripped from the tools affinity key like
cache_control. The Claude cache planning in completion() now uses the resolved
reasoning effort, thinking and output_config that the real call sends, and it
moves into a helper so completion() stays under the type checker's complexity
limit
@mateo-berri

Copy link
Copy Markdown
Contributor Author

The post-merge audit passed at this PR's merge commit. Its integration tests and one stale cell fix are in #48910

mateo-berri added a commit that referenced this pull request Oct 28, 2026
* test(routing): audit #46601

Adds integration cells for the falsy budget 400, the empty and none-only declarations under drop_params, Vertex AI Claude, Databricks Claude, and the Bedrock native output retry

* test(routing): expect the Anthropic default max_tokens on Bedrock Invoke chat

Reads the default from litellm instead of pinning 4096, which #48502 raised to 128000

* test(routing): assert whole sent bodies in the Vertex AI and Bedrock native output cells

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high Sensitive, broad, or high-risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants