Skip to content

fix(bedrock): stop leaking Anthropic thinking/reasoning_effort into DeepSeek Converse requests - #33409

Merged
mateo-berri merged 7 commits into
litellm_internal_stagingfrom
litellm_fix_bedrock_deepseek_thinking_leak
Sep 10, 2026
Merged

mateo-berri merged 7 commits into
litellm_internal_stagingfrom
litellm_fix_bedrock_deepseek_thinking_leak

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Bedrock DeepSeek R1 400s when thinking or reasoning_effort is sent
  • LiteLLM forwarded the Anthropic thinking block to every "reasoning" model
  • DeepSeek V3 silently ignored the Anthropic block, so reasoning_effort did nothing

How it solves it:

  • DeepSeek no longer advertises the Anthropic thinking param
  • R1 also stops advertising reasoning_effort, so callers get a clear client-side error
  • V3 forwards reasoning_effort raw, the way gpt-oss does, and reasoning actually turns on
  • map_openai_params drops the fields for direct calls too, so nothing leaks

User Flow

Before: a developer calling DeepSeek R1 on Bedrock through the gateway gets an opaque AWS error the moment they ask for reasoning, and DeepSeek V3 quietly ignores the ask

  1. They send POST https://litellm-domain/v1/chat/completions with "model": "bedrock-deepseek-r1" and "thinking": {"type": "enabled", "budget_tokens": 1024}
  2. They get HTTP 400 with BedrockException - {"message":"The model returned the following errors: Validation Error"}, no hint of which field AWS rejected
  3. They retry with "reasoning_effort": "high" instead, and with drop_params: true on the deployment, and get the same opaque 400 every time
  4. They send POST https://litellm-domain/v1/messages with the same model and thinking block and get the same 400
  5. They switch to "model": "bedrock-deepseek-v3" with "reasoning_effort": "high" and get HTTP 200, but reasoning_content is null and the answer used 2 completion tokens: no reasoning happened

After: the same developer gets a clear error naming the unsupported field, a working call once they drop it, and real reasoning from DeepSeek V3

  1. They send POST https://litellm-domain/v1/chat/completions with "model": "bedrock-deepseek-r1" and "thinking": {"type": "enabled", "budget_tokens": 1024}
  2. They get HTTP 400 with bedrock does not support parameters: ['thinking'], for model=us.deepseek.r1-v1:0. To drop these, set litellm.drop_params=True before anything reaches AWS
  3. They retry with "reasoning_effort": "high" and drop_params: true on the deployment and get HTTP 200 with reasoning_content filled and 391 in the answer
  4. They send POST https://litellm-domain/v1/messages with the same model and thinking block and get the same clear HTTP 400 naming the field, and on the drop_params: true deployment HTTP 200 with a thinking block followed by a text block
  5. They switch to "model": "bedrock-deepseek-v3" with "reasoning_effort": "high" and get HTTP 200 with reasoning_content filled and 151 completion tokens: reasoning is on

Relevant issues

Fixes #33401 (also covers the DeepSeek part of #13959)

Linear ticket

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/test_litellm/<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
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

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

Two no-DB proxies on the config below, each booted with --num_workers 2 (2 uvicorn workers, the same topology on both legs), hitting real Bedrock with a bearer token. The before proxy runs the merge base ee7c7e1 on port 28682, the after proxy runs this PR's tip 263c34f on port 33394. 263c34f is dd707da merged with litellm_internal_staging (conflict resolution in converse_transformation.py only, no other change), so the run below is the fresh one at the merged tree. bedrock-deepseek-r1, bedrock-deepseek-v3 and bedrock-deepseek-v31 are plain deployments, the -drop variants set drop_params: true, and bedrock-claude is us.anthropic.claude-sonnet-4-6 as the control

model_list:
  - model_name: bedrock-deepseek-r1
    litellm_params: {model: bedrock/us.deepseek.r1-v1:0, aws_region_name: us-east-1}
  - model_name: bedrock-deepseek-r1-drop
    litellm_params: {model: bedrock/us.deepseek.r1-v1:0, aws_region_name: us-east-1, drop_params: true}
  - model_name: bedrock-deepseek-v3
    litellm_params: {model: bedrock/deepseek.v3.2, aws_region_name: us-east-1}
  - model_name: bedrock-deepseek-v3-drop
    litellm_params: {model: bedrock/deepseek.v3.2, aws_region_name: us-east-1, drop_params: true}
  - model_name: bedrock-deepseek-v31
    litellm_params: {model: bedrock/deepseek.v3-v1:0, aws_region_name: us-west-2}
  - model_name: bedrock-claude
    litellm_params: {model: bedrock/us.anthropic.claude-sonnet-4-6, aws_region_name: us-east-1}
  - model_name: bedrock-gpt-oss
    litellm_params: {model: bedrock/openai.gpt-oss-120b-1:0, aws_region_name: us-west-2}
  - model_name: bedrock-nova2
    litellm_params: {model: bedrock/us.amazon.nova-2-lite-v1:0, aws_region_name: us-east-1}
  - model_name: bedrock-gpt6
    litellm_params: {model: bedrock/us.openai.gpt-6-astra, aws_region_name: us-east-1}

Every chat call below is curl -s -o body.json -w 'HTTP %{http_code} ' http://localhost:$PORT/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"<model>","messages":[{"role":"user","content":"What is 17*23? Answer with just the number."}],"max_tokens":600, <param>}' followed by jq -c 'if .choices then {content: .choices[0].message.content, reasoning: (.choices[0].message.reasoning_content|tostring|.[0:60]), completion_tokens: .usage.completion_tokens} else .error.message[0:260] end' body.json. /v1/messages calls add -H 'anthropic-version: 2023-06-01' and the Anthropic body shape with "thinking":{"type":"enabled","budget_tokens":1024} (jq prints {blocks: [.content[].type], text, output_tokens}), /v1/responses calls send "input", "max_output_tokens":2048 and "reasoning":{"effort":"high"} (jq prints {types: [.output[].type], text, out_tokens}), and streaming calls add "stream":true and print one R per reasoning_content delta and one C per content delta

Before (ee7c7e1, port 28682, 2 workers)

/v1/chat/completions, DeepSeek R1 with thinking

  1. <param> = "thinking":{"type":"enabled","budget_tokens":1024}, model bedrock-deepseek-r1
  2. HTTP 400 "litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: Validation Error\"}. Received Model Group=bedrock-deepseek-r1"

/v1/chat/completions, DeepSeek R1 with reasoning_effort

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-r1 (identical with "low")
  2. HTTP 400 "litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: Validation Error\"}. Received Model Group=bedrock-deepseek-r1"

/v1/chat/completions, DeepSeek R1 with reasoning_effort, drop_params: true

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-r1-drop
  2. HTTP 400 "litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: Validation Error\"}. Received Model Group=bedrock-deepseek-r1-drop" (drop_params did not help because the field was advertised as supported)

/v1/chat/completions, DeepSeek R1 with reasoning_effort, streaming

  1. Same body plus "stream":true, model bedrock-deepseek-r1 (identical on bedrock-deepseek-r1-drop)
  2. No data: chunks, just HTTP 400 {"error":{"message":"litellm.BadRequestError: BedrockException - validationException {\"message\":\"The model returned the following errors: Validation Error\"}","type":null,"param":null,"code":"400"}}

/v1/messages, DeepSeek R1 with thinking

  1. Body {"model":"bedrock-deepseek-r1","max_tokens":600,"messages":[...],"thinking":{"type":"enabled","budget_tokens":1024}}
  2. HTTP 400 {"type":"invalid_request_error","message":"litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: Validation Error\"}. Received Model Group=bedrock-deepseek-r1"}

/v1/messages, DeepSeek R1 with thinking, drop_params: true

  1. Same body, model bedrock-deepseek-r1-drop
  2. HTTP 400 {"type":"invalid_request_error","message":"litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: Validation Error\"}. Received Model Group=bedrock-deepseek-r1-drop"}

/v1/responses, DeepSeek R1 with reasoning.effort

  1. Body {"model":"bedrock-deepseek-r1","input":"What is 17*23? Answer with just the number.","max_output_tokens":2048,"reasoning":{"effort":"high"}}
  2. HTTP 400 "litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: Validation Error\"}. Received Model Group=bedrock-deepseek-r1"

/v1/responses, DeepSeek R1 with reasoning.effort, drop_params: true

  1. Same body, model bedrock-deepseek-r1-drop
  2. HTTP 400 "litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: Validation Error\"}. Received Model Group=bedrock-deepseek-r1-drop"

/v1/chat/completions, DeepSeek V3 with thinking

  1. <param> = "thinking":{"type":"enabled","budget_tokens":1024}, model bedrock-deepseek-v3
  2. HTTP 200 {"content":"391","reasoning":"null","completion_tokens":2} (the Anthropic-shaped block was silently ignored)

/v1/chat/completions, DeepSeek V3 with reasoning_effort

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-v3
  2. HTTP 200 {"content":"391","reasoning":"null","completion_tokens":2} (no reasoning: reasoning_effort was translated into the Anthropic block AWS ignores)

/v1/chat/completions, DeepSeek V3 with reasoning_effort: "low"

  1. <param> = "reasoning_effort":"low", model bedrock-deepseek-v3
  2. HTTP 200 {"content":"391","reasoning":"null","completion_tokens":2}

/v1/chat/completions, DeepSeek V3 with reasoning_effort, streaming

  1. Same body plus "stream":true
  2. C

/v1/messages, DeepSeek V3 with thinking

  1. Body {"model":"bedrock-deepseek-v3","max_tokens":600,"messages":[...],"thinking":{"type":"enabled","budget_tokens":1024}}
  2. HTTP 200 {"blocks":["text"],"text":"391","output_tokens":2} (no thinking block)

/v1/responses, DeepSeek V3 with reasoning.effort

  1. Body {"model":"bedrock-deepseek-v3","input":"What is 17*23? Answer with just the number.","max_output_tokens":2048,"reasoning":{"effort":"high"}}
  2. HTTP 200 {"types":["message"],"text":"Let's calculate \\(17 \\times 23\\):\n\n\\[\n17","out_tokens":60} (no reasoning item)

/v1/chat/completions, DeepSeek V3.1 with reasoning_effort

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-v31
  2. HTTP 200 {"content":"I apologize for the error in my previous response. Let me correct that.\n\n17 * 23 = 391\n\nThe correct answer is 391.","reasoning":"null","completion_tokens":31} (no reasoning; thinking and "low" also return 200 with reasoning null, streaming prints C)

/v1/messages and /v1/responses, DeepSeek V3.1

  1. Same /v1/messages and /v1/responses bodies as the V3 cases, model bedrock-deepseek-v31
  2. HTTP 200 {"blocks":["text"],"text":"391","output_tokens":2} and HTTP 200 {"types":["message"],"text":"The product of 17 and 23 is:\n\n17 * 23 = ","out_tokens":25} (no reasoning on either)

/v1/chat/completions and /v1/messages, Claude control with thinking

  1. <param> = "thinking":{"type":"enabled","budget_tokens":1024}, model bedrock-claude
  2. HTTP 200 {"content":"391","reasoning":"391","completion_tokens":13} and HTTP 200 {"blocks":["thinking","text"],"text":"391","output_tokens":13}

After (263c34f, port 33394, 2 workers)

/v1/chat/completions, DeepSeek R1 with thinking

  1. <param> = "thinking":{"type":"enabled","budget_tokens":1024}, model bedrock-deepseek-r1
  2. HTTP 400 "litellm.UnsupportedParamsError: bedrock does not support parameters: ['thinking'], for model=us.deepseek.r1-v1:0. To drop these, set litellm.drop_params=True or for proxy:\n\nlitellm_settings:\n drop_params: true" (raised before the request leaves the gateway)

/v1/chat/completions, DeepSeek R1 with reasoning_effort

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-r1 (identical with "low")
  2. HTTP 400 "litellm.UnsupportedParamsError: bedrock does not support parameters: ['reasoning_effort'], for model=us.deepseek.r1-v1:0. To drop these, set litellm.drop_params=True or for proxy:\n\nlitellm_settings:\n drop_params: true"

/v1/chat/completions, DeepSeek R1 with reasoning_effort, drop_params: true

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-r1-drop
  2. HTTP 200 {"content":"","reasoning":"Okay, so I need to calculate 17 multiplied by 23. Let me thi","completion_tokens":600} (the field is dropped and R1 reasons natively; thinking and "low" on this deployment also return 200 with reasoning)

/v1/chat/completions, DeepSeek R1 with reasoning_effort, streaming

  1. Same body plus "stream":true, model bedrock-deepseek-r1
  2. No data: chunks, just HTTP 400 {"error":{"message":"litellm.UnsupportedParamsError: bedrock does not support parameters: ['reasoning_effort'], for model=us.deepseek.r1-v1:0. To drop these, set litellm.drop_params=True or for proxy: ...","type":null,"param":null,"code":"400"}}

/v1/chat/completions, DeepSeek R1 with reasoning_effort, drop_params: true, streaming

  1. Same body plus "stream":true, model bedrock-deepseek-r1-drop
  2. RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... (reasoning deltas stream until max_tokens)

/v1/messages, DeepSeek R1 with thinking

  1. Body {"model":"bedrock-deepseek-r1","max_tokens":600,"messages":[...],"thinking":{"type":"enabled","budget_tokens":1024}}
  2. HTTP 400 {"type":"invalid_request_error","message":"litellm.UnsupportedParamsError: bedrock does not support parameters: ['reasoning_effort'], for model=us.deepseek.r1-v1:0. To drop these, set litellm.drop_params=True or for proxy:\n\nlitellm_settings:\n drop_params: true\n. \n If you want to use these params dynamically send allowed_openai_params=['reasoning_effort'] in your request.. Received Model Group=bedrock-deepseek-r1\nAvailable Model Group Fallbacks=None"} (the Anthropic adapter translates thinking into reasoning_effort before the Bedrock config sees it, so that is the field named)

/v1/messages, DeepSeek R1 with thinking, drop_params: true

  1. Same body, model bedrock-deepseek-r1-drop
  2. HTTP 200 {"blocks":["thinking","text"],"text":"","output_tokens":600} (R1 spent the whole 600-token budget in its native thinking block)

/v1/responses, DeepSeek R1 with reasoning.effort

  1. Body {"model":"bedrock-deepseek-r1","input":"What is 17*23? Answer with just the number.","max_output_tokens":2048,"reasoning":{"effort":"high"}}
  2. HTTP 400 "litellm.UnsupportedParamsError: bedrock does not support parameters: ['reasoning_effort'], for model=us.deepseek.r1-v1:0. To drop these, set litellm.drop_params=True or for proxy:\n\nlitellm_settings:\n drop_params: true"

/v1/responses, DeepSeek R1 with reasoning.effort, drop_params: true

  1. Same body, model bedrock-deepseek-r1-drop
  2. HTTP 200 {"types":["reasoning","message"],"text":"\n\n391","out_tokens":441}

/v1/chat/completions, DeepSeek V3 with thinking

  1. <param> = "thinking":{"type":"enabled","budget_tokens":1024}, model bedrock-deepseek-v3
  2. HTTP 400 "litellm.UnsupportedParamsError: bedrock does not support parameters: ['thinking'], for model=deepseek.v3.2. To drop these, set litellm.drop_params=True or for proxy:\n\nlitellm_settings:\n drop_params: true" (on bedrock-deepseek-v3-drop the same call returns HTTP 200 with the worked answer and reasoning null)

/v1/chat/completions, DeepSeek V3 with reasoning_effort

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-v3
  2. HTTP 200 {"content":"391","reasoning":"We are asked: \"What is 17*23? Answer with just the number.\" ","completion_tokens":122} (real reasoning, since reasoning_effort now reaches Bedrock raw)

/v1/chat/completions, DeepSeek V3 with reasoning_effort: "low"

  1. <param> = "reasoning_effort":"low", model bedrock-deepseek-v3
  2. HTTP 200 {"content":"391","reasoning":"null","completion_tokens":2} (Bedrock accepts low and answers without reasoning)

/v1/chat/completions, DeepSeek V3 with reasoning_effort, streaming

  1. Same body plus "stream":true
  2. RRRRRRRRRRC

/v1/messages, DeepSeek V3 with thinking

  1. Body {"model":"bedrock-deepseek-v3","max_tokens":600,"messages":[...],"thinking":{"type":"enabled","budget_tokens":1024}}
  2. HTTP 200 {"blocks":["text"],"text":"First, note that \\(17 \\times 23\\) can be","output_tokens":73} (the adapter maps a 1024 budget to reasoning_effort: "low", which V3 answers without reasoning, same as before)

/v1/responses, DeepSeek V3 with reasoning.effort

  1. Body {"model":"bedrock-deepseek-v3","input":"What is 17*23? Answer with just the number.","max_output_tokens":2048,"reasoning":{"effort":"high"}}
  2. HTTP 200 {"types":["reasoning","message"],"text":"391","out_tokens":94}

/v1/chat/completions, DeepSeek V3.1 with reasoning_effort

  1. <param> = "reasoning_effort":"high", model bedrock-deepseek-v31
  2. HTTP 200 {"content":"391","reasoning":"First, the question is to multiply 17 by 23. I need to give ","completion_tokens":370} (streaming prints RRRRRRRRRRC; thinking now 400s with UnsupportedParamsError ... ['thinking'], for model=deepseek.v3-v1:0; "low" returns 200 with reasoning null)

/v1/messages and /v1/responses, DeepSeek V3.1

  1. Same /v1/messages and /v1/responses bodies as the V3 cases, model bedrock-deepseek-v31
  2. HTTP 200 {"blocks":["text"],"text":"To calculate \\(17 \\times 23\\):\n\n\\[\n17 \\t","output_tokens":39} and HTTP 200 {"types":["reasoning","message"],"text":"391","out_tokens":203}

/v1/chat/completions and /v1/messages, Claude control with thinking

  1. <param> = "thinking":{"type":"enabled","budget_tokens":1024}, model bedrock-claude
  2. HTTP 200 {"content":"391","reasoning":"391","completion_tokens":13} and HTTP 200 {"blocks":["thinking","text"],"text":"391","output_tokens":13} (unchanged)

Other Bedrock reasoning models, before and after

Since 263c34f merges the staging fix for GPT-6 into this branch, the neighbouring reasoning paths were re-run on both trees with "reasoning_effort":"low" and "max_tokens":2048. Both proxies for this block were booted the same way with LITELLM_LOCAL_MODEL_COST_MAP=True, because the hosted cost map does not list us.openai.gpt-6-astra yet and without it the model is routed to the invoke API on either tree

  1. bedrock-gpt-oss: before HTTP 200 {"content":"391","reasoning":"Just compute. 17*23 = 391.","completion_tokens":22}, after HTTP 200 {"content":"391","reasoning":"Just compute. 17*23 = 391.","completion_tokens":22}
  2. bedrock-nova2: before HTTP 200 {"content":"391","reasoning":"[REDACTED].","completion_tokens":247}, after HTTP 200 {"content":"391","reasoning":"[REDACTED].","completion_tokens":261}
  3. bedrock-gpt6: before HTTP 400 "litellm.UnsupportedParamsError: bedrock does not support parameters: ['reasoning_effort'], for model=us.openai.gpt-6-astra..." (the merge base predates the staging fix), after HTTP 200 {"content":"391","reasoning":"null","completion_tokens":5}
  4. bedrock-gpt6 with thinking: HTTP 400 "litellm.UnsupportedParamsError: bedrock does not support parameters: ['thinking'], for model=us.openai.gpt-6-astra..." on both trees, which is what staging does today
  5. bedrock-claude with reasoning_effort: "low": HTTP 200 {"content":"391","reasoning":"null","completion_tokens":5} on both trees

Observations from the run, none caused by this PR:

  • /v1/messages errors name reasoning_effort, not thinking, after adapter translation
  • /v1/messages maps a 1024 budget to low, so V3 skips reasoning
  • DeepSeek V3 and V3.1 reason only at reasoning_effort: "high"
  • R1 with max_tokens: 600 can spend it all on reasoning
  • R1 streaming 400s arrive as a plain JSON body, no data: chunks
  • V3 with thinking and drop_params answers without reasoning, same as before

Type

🐛 Bug Fix

Caveats (if any)

Low

  • reasoning_effort is forwarded to DeepSeek V3 verbatim, a deliberate choice
    • Bedrock validates the field itself (minimal gets a Bedrock 400 naming none, low, medium, high), so the gateway does not narrow it
    • Clamping sub-high values to high was rejected: V3 and V3.1 only reason at high, but overriding an explicit caller value would hide that
    • The /v1/messages budget-to-effort mapping (1024 tokens becomes low) is shared by every non-Claude Bedrock model and is unchanged here
  • DeepSeek V3 with Anthropic thinking now fails client-side (or is dropped with drop_params) where it used to return 200 with the block silently ignored
  • DeepSeek behind an arn: deployment is still not introspected
    • The ARN path keeps advertising thinking as before; a foundation-model ARN that resolves to DeepSeek has the field dropped by the mapping step with a debug log
  • Non-DeepSeek reasoning models outside the Claude, Nova 2, gpt-oss and GPT allowlists (Qwen3, for one) still get the Anthropic thinking block, tracked in [Bug]: Bedrock Converse silently drops reasoning_effort for non-Anthropic/Nova2/GPT-OSS models (e.g. Qwen3 on Bedrock) #34105
    • Inverting that default here would touch every Bedrock reasoning model, which is the regression this PR was asked not to risk
  • is_thinking_enabled is computed before the DeepSeek drop, which is unobservable today: V3 uses native structured outputs and R1 has no tool_choice support

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

Link to Devin session: https://app.devin.ai/sessions/e5e483ac1ef148fa9c0348e314377e1d


Note

Medium Risk
Changes Bedrock Converse parameter routing for reasoning across DeepSeek variants; well-tested but touches shared map_openai_params / supported-params logic used by many models.

Overview
Fixes Bedrock Converse handling so DeepSeek models no longer receive Anthropic-shaped thinking / mis-mapped reasoning_effort in additionalModelRequestFields, which caused R1 AWS 400s and left V3 reasoning ineffective.

Supported params: DeepSeek stops advertising thinking and output_config. R1 no longer advertises reasoning_effort (client-side UnsupportedParamsError instead of opaque Bedrock errors). V3 advertises reasoning_effort and passes it through raw (same path as gpt-oss), not via Anthropic thinking mapping.

Request mapping: New DeepSeek-specific guards in map_openai_params drop thinking for all DeepSeek models and drop reasoning_effort for R1 (with debug logs); _handle_reasoning_effort_parameter treats DeepSeek like gpt-oss for passthrough. Claude, Nova 2, gpt-oss, and inference-profile paths are covered by regression tests so only DeepSeek is affected.

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

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

CLAassistant commented Jul 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ mateo-berri
❌ devin-ai-integration[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects Bedrock Converse reasoning-parameter handling and preserves JSON-mode response transformation.

  • Stops advertising or forwarding Anthropic-shaped thinking for DeepSeek models.
  • Drops reasoning_effort for DeepSeek R1 while forwarding it raw for DeepSeek V3.
  • Generalizes OpenAI Bedrock reasoning handling from GPT-5 to numbered GPT model families, including GPT-6.
  • Propagates the resolved JSON-mode setting into response transformation.
  • Adds focused regression coverage for DeepSeek, OpenAI GPT-6, Claude, GPT-OSS, Nova, inference-profile, and JSON-mode behavior.

Confidence Score: 5/5

The PR appears safe to merge; no outstanding correctness, security, or repository-rule issue remains.

The current implementation prevents unsupported DeepSeek fields from reaching Bedrock, forwards DeepSeek V3 reasoning effort in the accepted raw shape, preserves other model families, and correctly carries JSON mode into response processing. The sole previous finding was manually resolved and is not outstanding.

Important Files Changed

Filename Overview
litellm/llms/bedrock/chat/converse_transformation.py Correctly specializes Bedrock reasoning-parameter advertisement and mapping for DeepSeek while preserving other reasoning-model paths and explicit JSON-mode handling.
tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py Adds targeted, network-free regression tests covering parameter advertisement, request shaping, non-DeepSeek preservation, GPT-6 detection, and JSON-mode response handling.

Reviews (4): Last reviewed commit: "Merge branch 'litellm_internal_staging' ..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...tellm/llms/bedrock/chat/converse_transformation.py 95.65% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_bedrock_deepseek_thinking_leak (263c34f) with litellm_internal_staging (db7ca65)

Open in CodSpeed

@shivamrawat1

Copy link
Copy Markdown
Contributor

@greptile review again

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

This will cause a regression. It's not gating the drop on DeepSeek only so Claude behind application-inference-profile ARNs, gpt-oss-safeguard, and Nova 2 custom-import ARNs will all silently degrade reasoning in prod

mateo-berri and others added 3 commits July 23, 2026 03:29
…lowlisted models

The DeepSeek leak fix gated the drop of thinking/reasoning_effort on a positive allowlist (_model_accepts_anthropic_thinking_param). Its negation dropped the params for any model the allowlist and ARN introspection missed, so Claude behind application-inference-profile ARNs, gpt-oss-safeguard (absent from the cost map so supports_reasoning is False), and Nova 2 custom-import ARNs all silently lost reasoning in prod.

Gate the drop on a narrow denylist instead: only DeepSeek reasons natively and 400s on the request field, so drop only there and leave every other model (including opaque ARNs and gpt-oss/Nova 2 which route reasoning_effort through their own shapes) untouched.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri
mateo-berri requested a review from a team September 9, 2026 03:29
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

❌ Cannot revive Devin session - the session is too old. Please start a new session instead.

View session

@mateo-berri

Copy link
Copy Markdown
Contributor

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

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

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 263c34f. Configure here.

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

LGTM

@mateo-berri
mateo-berri merged commit 2611f64 into litellm_internal_staging Sep 10, 2026
83 of 84 checks passed
@mateo-berri
mateo-berri deleted the litellm_fix_bedrock_deepseek_thinking_leak branch September 10, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bedrock DeepSeek R1 rejects requests with thinking/reasoning_effort (400 Validation Error) — additionalModelRequestFields leak

3 participants