Skip to content

fix(anthropic): drop unknown legacy thinking keys under drop_params when rebuilding adaptive thinking - #46741

Merged
mateo-berri merged 4 commits into
mainfrom
litellm_drop_unknown_legacy_thinking_keys
Oct 15, 2026
Merged

mateo-berri merged 4 commits into
mainfrom
litellm_drop_unknown_legacy_thinking_keys

Conversation

@mateo-berri

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

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Unknown keys drop under drop_params when LiteLLM rebuilds thinking
  • Without drop_params, Claude's 400 still comes back
  • block_binding and supported display values are always kept
  • Under drop_params, rebuilt adaptive thinking also drops budget_tokens

User Flow

Before: a developer with drop_params on gets a 400 when legacy thinking carries a key Claude does not know

  1. They send POST https://litellm-domain/v1/chat/completions (or /v1/messages) to Claude Opus 5.5 with "drop_params": true
  2. thinking is {"type": "enabled", "budget_tokens": 2048, "not_a_real_key": true}
  3. They get HTTP 400 thinking.adaptive.not_a_real_key: Extra inputs are not permitted

After: the same request returns 200, and block_binding in the same object still applies

  1. They send POST https://litellm-domain/v1/chat/completions (or /v1/messages) to Claude Opus 5.5 with "drop_params": true
  2. thinking is {"type": "enabled", "budget_tokens": 2048, "not_a_real_key": true}
  3. They get HTTP 200 with Claude's answer
  4. Without drop_params the same request still returns the 400

Relevant issues

Follow-up to #46342

Design decisions

Every rebuild produces adaptive thinking, so known keys are the adaptive fields of LiteLLM's Anthropic thinking type (type, display, block_binding). Always dropping the rest would also drop new Anthropic keys, so unknown keys follow the usual drop_params rule and get the provider's 400 without it. Only thinking that LiteLLM rebuilds is filtered, since filtering every Claude route changes requests that work today

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

Last updated: 96797b4. QA and /live-pr-risk ran on 59e3bb4, the last commit with a product diff

Two 2-worker proxies call real providers, Before at the merge base and After at 59e3bb4. Cells read chat/messages. Cases send legacy thinking with not_a_real_key and drop_params: true unless named otherwise, and the last two rows set only global drop_params. Every Before 400 is Extra inputs are not permitted, and the After block_binding: error 400 is the binding mismatch

Case Before After
Anthropic, body drop_params 400/400 200/200
Anthropic, deployment drop_params 400/400 200/200
Bedrock Invoke 400/400 200/200
Vertex AI 400/400 200/200
Bedrock Converse 400/400 200/200
Databricks 400/400 200/200
Bedrock Invoke, adaptive display: updates 400/400 200/200
Bedrock Invoke, adaptive budget_tokens 400/400 200/200
Control, drop_params: false 400/400 400/400
block_binding: error, foreign block 400/400 400/400
block_binding: drop_block, foreign block 400/400 200/200
Global drop_params 400/400 200/200
Bedrock Opus 4.6, clear_thinking edit n/a / 400 n/a / 200

Each proxy's boot, commands and raw output are in the gist linked from each cell

Integration audit

The matrix ran at base 54ff82d and head 96797b4. Five drop cells (body, deployment and Claude Code's default drop_params on /v1/messages, Bedrock Invoke chat and messages) fail on base and pass twice on head, and the 52 other cells pass on both

Proxy config
model_list:
  - model_name: claude-opus
    litellm_params: {model: anthropic/claude-opus-5-5}
  - model_name: claude-sonnet
    litellm_params: {model: anthropic/claude-sonnet-5-5}
  - model_name: bedrock-opus
    litellm_params: {model: bedrock/invoke/us.anthropic.claude-opus-5-5, aws_region_name: us-east-1}
  - model_name: bedrock-sonnet
    litellm_params: {model: bedrock/invoke/us.anthropic.claude-sonnet-5-5, aws_region_name: us-east-1}
  - model_name: vertex-opus
    litellm_params: {model: vertex_ai/claude-opus-5-5, vertex_project: os.environ/VERTEXAI_PROJECT, vertex_location: global}
  - model_name: vertex-sonnet
    litellm_params: {model: vertex_ai/claude-sonnet-5-5, vertex_project: os.environ/VERTEXAI_PROJECT, vertex_location: global}
  - model_name: claude-opus-dropparams
    litellm_params: {model: anthropic/claude-opus-5-5, drop_params: true}
  - model_name: bedrock-converse-opus
    litellm_params: {model: bedrock/converse/us.anthropic.claude-opus-5-5, aws_region_name: us-east-1}
  - model_name: databricks-opus
    litellm_params: {model: databricks/databricks-claude-opus-5-5}

The second pair adds these lines

  - model_name: bedrock-opus-46
    litellm_params: {model: bedrock/invoke/us.anthropic.claude-opus-4-6-v1, aws_region_name: us-east-1}
litellm_settings:
  drop_params: true

Before (54ff82d)

Anthropic, body drop_params

  1. /v1/chat/completions
curl -s -w '\nHTTP %{http_code}\n' http://127.0.0.1:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
  -d '{"model": "claude-opus", "max_tokens": 4096, "drop_params": true, "thinking": {"type": "enabled", "budget_tokens": 2048, "not_a_real_key": true}, "messages": [{"role": "user", "content": "Is 391 prime? One word."}]}'
  1. Raw output
{"error":{"message":"litellm.BadRequestError: AnthropicException - {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"thinking.adaptive.not_a_real_key: Extra inputs are not permitted\"},\"request_id\":\"req_011Cg4fGmHUMAVzmfNTXcGsc\"}\n\nLiteLLM: model group 'claude-opus' failed with the error above. No fallback was attempted.","type":"invalid_request_error","param":null,"code":"400"}}
HTTP 400
Same request on /v1/messages
  1. /v1/messages, the same body
curl -s -w '\nHTTP %{http_code}\n' http://127.0.0.1:$PORT/v1/messages -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
  -d '{"model": "claude-opus", "max_tokens": 4096, "drop_params": true, "thinking": {"type": "enabled", "budget_tokens": 2048, "not_a_real_key": true}, "messages": [{"role": "user", "content": "Is 391 prime? One word."}]}'
  1. Raw output
{"type":"error","error":{"type":"invalid_request_error","message":"litellm.BadRequestError: AnthropicException - {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"thinking.adaptive.not_a_real_key: Extra inputs are not permitted\"},\"request_id\":\"req_011Cg4fGpRVECLffCqg7UAWU\"}\n\nLiteLLM: model group 'claude-opus' failed with the error above. No fallback was attempted."}}
HTTP 400

After (59e3bb4)

Anthropic, body drop_params

  1. /v1/chat/completions
curl -s -w '\nHTTP %{http_code}\n' http://127.0.0.1:$PORT/v1/chat/completions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
  -d '{"model": "claude-opus", "max_tokens": 4096, "drop_params": true, "thinking": {"type": "enabled", "budget_tokens": 2048, "not_a_real_key": true}, "messages": [{"role": "user", "content": "Is 391 prime? One word."}]}'
  1. Raw output
{"id":"chatcmpl-edc5857a-caec-45e6-96c9-c5b56238c28f","created":1792099411,"model":"claude-opus","object":"chat.completion","choices":[{"finish_reason":"stop","index":0,"message":{"content":"No.","role":"assistant","reasoning_content":"","thinking_blocks":[{"type":"thinking","thinking":"","signature":"CAQS8QQKEAgSGAI4AUIIdGhpbmtpbmcSDDvsYGWJT2tvg0m7BRoMDTCWsb3uPHDiy5IQIjDPR4wZWUcqL0qQEX/ifSHoFD3RLu22WgKE/bnk4vpidQO+W2SkXR+0oVFFfEmlmewqjgRnzAPA7QYq+hMD+mgyely7cDBEmQhvwBdx/12YNktpWlp7/n2wT9LIb4aQGVBzXxc85zLmONWgXoYmK31/1E8GyDonq5x+w8KdjAeVmH85dEa2CWdRFU30NyKYU9KjWItGV5TLOb2NnfLEJWvdiDqPX7G9IgWjrH/eKwWLKoIgRPzIyoi5gUqlIhmQNrD0cnuZx718Xi1+6uKPDcnyfDh8Hv/Uu6xWvuCbua407xkgYxJWzDtAYiU4jzcKqJpCsJhkIaqsWcVdorO19/I2hNTzknKWMf6C38DryjtNN3r+2e5WzT1zUd6GbPm49wxtpCwnGMbJhmz+Kc8UAB3zuaFj//5EDXfwvHdAS0XEJFVa+i2oMSo5QJg8hlN2Yv0F+/Y01ndv4ea1juw74csfPXF0HlvH98PSro9L8HJcLxx6C/9EjRZuUQWtyb5GfnK1ws6N8O6yUNdP2lW7l2dTdhN7DN2EwFFDzzTTLxi+5dWaP6LbLpFXxBRNb/aPEPizjvR/TaeSj5xJK2Szjfr6Dfm/shX9mBrUtpjNZJimO2L/ubmd37ph4F2Iad5C4GZp4lb0Z2WjP06w4VgRC18y/HOh5nvMadmdsT0kBi7QAQQmx3aWE+AjbGNHxTMXn+Tv0cGoz4IppjhwyPaQsv6wxtnJzm8HwfLb/c+xyoNdEsx6Y7JrE0gkPPgnkHEmZLOTGAE="}],"provider_specific_fields":{"citations":null,"thinking_blocks":[{"type":"thinking","thinking":"","signature":"CAQS8QQKEAgSGAI4AUIIdGhpbmtpbmcSDDvsYGWJT2tvg0m7BRoMDTCWsb3uPHDiy5IQIjDPR4wZWUcqL0qQEX/ifSHoFD3RLu22WgKE/bnk4vpidQO+W2SkXR+0oVFFfEmlmewqjgRnzAPA7QYq+hMD+mgyely7cDBEmQhvwBdx/12YNktpWlp7/n2wT9LIb4aQGVBzXxc85zLmONWgXoYmK31/1E8GyDonq5x+w8KdjAeVmH85dEa2CWdRFU30NyKYU9KjWItGV5TLOb2NnfLEJWvdiDqPX7G9IgWjrH/eKwWLKoIgRPzIyoi5gUqlIhmQNrD0cnuZx718Xi1+6uKPDcnyfDh8Hv/Uu6xWvuCbua407xkgYxJWzDtAYiU4jzcKqJpCsJhkIaqsWcVdorO19/I2hNTzknKWMf6C38DryjtNN3r+2e5WzT1zUd6GbPm49wxtpCwnGMbJhmz+Kc8UAB3zuaFj//5EDXfwvHdAS0XEJFVa+i2oMSo5QJg8hlN2Yv0F+/Y01ndv4ea1juw74csfPXF0HlvH98PSro9L8HJcLxx6C/9EjRZuUQWtyb5GfnK1ws6N8O6yUNdP2lW7l2dTdhN7DN2EwFFDzzTTLxi+5dWaP6LbLpFXxBRNb/aPEPizjvR/TaeSj5xJK2Szjfr6Dfm/shX9mBrUtpjNZJimO2L/ubmd37ph4F2Iad5C4GZp4lb0Z2WjP06w4VgRC18y/HOh5nvMadmdsT0kBi7QAQQmx3aWE+AjbGNHxTMXn+Tv0cGoz4IppjhwyPaQsv6wxtnJzm8HwfLb/c+xyoNdEsx6Y7JrE0gkPPgnkHEmZLOTGAE="}]}}}],"usage":{"completion_tokens":40,"prompt_tokens":19,"total_tokens":59,"completion_tokens_details":{"reasoning_tokens":36,"text_tokens":4},"prompt_tokens_details":{"cached_tokens":0,"text_tokens":19,"cache_write_tokens":0,"cache_creation_tokens":0,"cache_creation_token_details":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0}},"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"inference_geo":"global","speed":"standard","service_tier":"standard"}}
HTTP 200
Same request on /v1/messages
  1. /v1/messages, the same body
curl -s -w '\nHTTP %{http_code}\n' http://127.0.0.1:$PORT/v1/messages -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
  -d '{"model": "claude-opus", "max_tokens": 4096, "drop_params": true, "thinking": {"type": "enabled", "budget_tokens": 2048, "not_a_real_key": true}, "messages": [{"role": "user", "content": "Is 391 prime? One word."}]}'
  1. Raw output
{"model":"claude-opus","id":"msg_011Cg4j5nyL7daEkgX54D7N5","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"CAQS3gQKEAgSGAI4AUIIdGhpbmtpbmcSDCfImLpbRPVHRtpiNRoMbYYoFgYV38Yz07cjIjC0Qs208Q7KpJpvj4VkDgeh1OmsaB2/Ul6a51vhx/dBJp5E7wckQLwZvGg5qMZbexkq+wOVKkAKyJWB22pV1VtQb0lDu5rfJ4J7kNWM0yst1mWASBMx9s+tYlxMT9nudUGug/F2chggF9Uz9JLnHd5VKIvv02KXrpTwL55GRVDln6Ym141SpNK0/p2VjkOupqPzC73PnKk1uDYsjIY36bhUjdtErv42qeJRNuVr2ef8ppZWEjJM0h+zbAb8WVdLYIxB5m4dSa9PVQGFt/qvQhuLY0OWuXU108fQaGV7F5pj/VONbD3vPMlBLSZExoOHMePVhWL19wRDphagBmhxJyL3jR3PhJ+V/3DxyUj1Br1WZuNcDfeMZ/6LkJKHZUIZe+YYnb5TBwxLl4UH5IXGSle8lMAspX4BKbhGgPE+LSU/8DbR7zKskfzDCgxwzALPCClrsIjEpChzCM/jNCffBpJCy9BsurtZZm/EJXOqkTZjynMDp7zYsNfXAjD8Ihk4upO3ulUuuTn4sAD+rXFMYCltmeaotFANTQsl27fnAIQqxLQWKcFyyW/4qE6nSL+kUEmjbCGQixV35s7CBqFH5Cv654orL00xJxgisaU5kfsyHZWEMiucjNdQLv98ZucMPq1QzAm41c5PDcvNPyQfT3WrIom3qcyVtd5RMM2vEkDIRpeA2Ysm3rDJ4buXygS0VzXZO7PUTq6Z1OX+fplEQ/cfwVrYnNhkcqg/Xf5OlTAYAQ=="},{"type":"text","text":"No. 391 = 17 × 23."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":45,"output_tokens_details":{"thinking_tokens":30},"service_tier":"standard","inference_geo":"global","speed":"standard"},"diagnostics":null}
HTTP 200

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • Without drop_params, an unknown key or an adaptive budget_tokens now 400s instead of dropping silently
  • With drop_params on, only rebuilt thinking drops unknown keys
    • Adaptive thinking on Opus 5.5 and legacy on Opus 4.6 still 400, as in the last release

Low

  • Known keys come from LiteLLM's type, so a new Anthropic key drops under drop_params until added, and the drop is not logged
  • The helper also reads the global litellm.drop_params, which the chat path needs
  • mcp-elicitation in the required unit rollup timed out once here and passed on a rerun. It also times out on recent main runs, and this PR does not touch it

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

  • 96797b4 passes /audit

  • 59e3bb4 passes /live-pr-risk

@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

@greptile-apps

greptile-apps Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@litereview

litereview Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

Completed · Some checks not run.

No correctness findings.

Checks and execution details
  • Passed · Real testing evidence (required): The rule applies because the PR changes how thinking requests are translated in litellm/llms/anthropic/**, litellm/llms/bedrock/**, litellm/llms/databricks/** and litellm/llms/vertex_ai/**.

The manual E2E evidence in gist 3f16d949 qualifies:

  • Setup: two 2-worker proxies called real providers (Anthropic, Bedrock Invoke and Converse, Vertex, Databricks). The Before proxy ran the merge base and the After proxy ran 59e3bb467e. The gist records the tree SHA, a clean status and the boot command.
  • Results: the gist has the raw curl commands and outputs. The drop_params request, deployment and global cases return HTTP 200. The drop_params: false control and the block_binding: error case still return HTTP 400.
  • Commit gap: GitHub compare shows head 96797b4 is one commit past 59e3bb467e. That commit changes only two integration test files, so the production code matches what the E2E run exercised.

I also ran the related unit tests locally: uv run --frozen pytest tests/unit/llms/anthropic/test_anthropic_common_utils.py tests/unit/llms/bedrock/messages/invoke_transformations/test_anthropic_claude3_transformation.py -k "thinking or clear or legacy". Result: 180 passed. The new wire integration tests need the CircleCI gateway harness, so I did not run them locally.

  • Not run · Full unit files for changed modules (optional): TestProxyOAuthHeaderForwarding in test_anthropic_common_utils.py fails locally with ModuleNotFoundError: No module named 'orjson', raised from litellm/proxy/common_utils/http_parsing_utils.py. That is a gap in the local environment and is unrelated to this diff. GitHub reports the py3.10 through py3.14 CI jobs as successful at the head SHA.
  • Passed · Caller audit for new drop_params parameter (optional): Every production caller of translate_legacy_thinking_for_adaptive_model, _ensure_thinking_for_clear_thinking_context_management and _inject_adaptive_thinking_for_clear_thinking now passes drop_params. The callers are Anthropic chat and pass-through, Bedrock Converse and Invoke chat, Bedrock messages, Databricks and Vertex. No caller still uses the old signature, and no remaining reference to the renamed _OBJECT_MAPPING_ADAPTER from common_utils exists.

View review · Reviewed 96797b46d164

@codspeed

codspeed Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 31 untouched benchmarks


Comparing litellm_drop_unknown_legacy_thinking_keys (96797b4) with main (67fab67)

Open in CodSpeed

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

… updates rebuilds

Bedrock Invoke copied every caller thinking key when adding display updates,
so an unknown key still reached the provider with drop_params on. Filter that
copy the same way, and cover each chat call site plus the global
litellm.drop_params path in tests
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litereview code-review

@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

@litereview code-review

@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

@litereview code-review

@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 96797b4. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litellm-stampbot

1 similar comment
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@litellm-stampbot

@litellm-stampbot

Copy link
Copy Markdown

litellm-stampbot: risk low

Approved at 96797b4.

Rules (stampbot/risk_rules.yml):

  • low: no rule flagged it

Judge (gpt-6-luna): low, probability of high 0.00 (high at or above 0.90)

  • risk: low (probability of high 0.00)

Pushes do not re-run this check. Comment @litellm-stampbot again to re-check the new head.

@litellm-stampbot litellm-stampbot Bot added the risk:low Small, isolated, low-risk change label Oct 15, 2026

@kerry-berri kerry-berri 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.

Low risk by rule and by judgement at 96797b4

@mateo-berri
mateo-berri merged commit d489c04 into main Oct 15, 2026
144 of 150 checks passed
@mateo-berri
mateo-berri deleted the litellm_drop_unknown_legacy_thinking_keys branch October 15, 2026 23:09
@yuneng-berri yuneng-berri mentioned this pull request Oct 20, 2026
2 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Small, isolated, low-risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants