Skip to content

fix(bedrock): use base_model for Claude capability checks on application inference profile ARNs - #46569

Merged
ryan-crabbe-berri merged 5 commits into
mainfrom
litellm_bedrock_arn_adaptive_thinking
Oct 15, 2026
Merged

ryan-crabbe-berri merged 5 commits into
mainfrom
litellm_bedrock_arn_adaptive_thinking

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Bedrock application inference profile ARNs hide which Claude model they point at
  • Adaptive thinking on an Opus 4.8 ARN gets rewritten into a fixed budget
  • Opus 4.8 rejects that with a 400, and Router fallbacks hide it
  • Setting base_model on the deployment did nothing

How it solves it:

  • Converse capability checks use base_model when the model is an app profile ARN
  • Covers both param mapping and request building (thinking, prompt caching, tool images)
  • Caching checks ask the ARN's own settings first, then base_model (markers and 1h ttl)
  • Plain model ids keep using the model name, exactly like today
  • An ARN with no base_model keeps today's behavior and logs a warning saying to set it

User Flow

Before: a team calling Opus 4.8 through an application inference profile ARN silently gets Sonnet answers instead

  1. The proxy admin adds a deployment with model: bedrock/arn:aws:bedrock:...:application-inference-profile/..., model_info.base_model: us.anthropic.claude-opus-4-8, and a fallback to Sonnet 4.6
  2. A developer sends POST https://litellm-domain/v1/chat/completions with "thinking": {"type": "adaptive"}
  3. Bedrock rejects the Opus call with 400 "thinking.type.enabled" is not supported for this model
  4. The response comes back 200 with x-litellm-attempted-fallbacks: 1 and "model": "us.anthropic.claude-sonnet-4-6"

After: the same request is answered by Opus through the ARN

  1. The proxy admin adds the same deployment with the same base_model
  2. The developer sends the same POST https://litellm-domain/v1/chat/completions with "thinking": {"type": "adaptive"}
  3. The response comes back 200 with x-litellm-model-id of the ARN deployment and x-litellm-attempted-fallbacks: 0
  4. If the admin left base_model off, the call still 400s like before and the proxy log now says to set base_model

Linear ticket

Resolves LIT-9588

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

Real Bedrock calls in us-east-1 against a temporary application inference profile copied from us.anthropic.claude-opus-4-8. The account id is masked as <acct> and the profile id as <profile-id>, since the profile was recreated between the two runs. Proxy config

model_list:
  - model_name: opus48
    litellm_params:
      model: bedrock/arn:aws:bedrock:us-east-1:<acct>:application-inference-profile/<profile-id>
      aws_region_name: us-east-1
    model_info:
      id: opus48-arn
      base_model: us.anthropic.claude-opus-4-8
  - model_name: opus48-no-base-model
    litellm_params:
      model: bedrock/arn:aws:bedrock:us-east-1:<acct>:application-inference-profile/<profile-id>
      aws_region_name: us-east-1
    model_info:
      id: opus48-arn-no-base-model
  - model_name: sonnet46
    litellm_params:
      model: bedrock/us.anthropic.claude-sonnet-4-6
      aws_region_name: us-east-1
    model_info:
      id: sonnet46-fallback
router_settings:
  fallbacks: [{"opus48": ["sonnet46"]}]
litellm_settings:
  drop_params: true
general_settings:
  master_key: sk-1234

Before ran from the merge base on port 4589 and After from the tip on port 4588, both with this config. Each case runs this request with only model changed, and the output is trimmed to the status line, the routing headers and the start of the body

curl -si http://localhost:$PORT/v1/chat/completions -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' \
  -d '{"model": "opus48", "max_tokens": 16000, "thinking": {"type": "adaptive", "display": "summarized"}, "messages": [{"role": "user", "content": "What is 17 * 23? Answer with just the number."}]}'

Before (0c91bd7)

ARN with base_model

  1. Send the request with "model": "opus48"
  2. Sonnet answers through the fallback
HTTP/1.1 200 OK
x-litellm-model-id: sonnet46-fallback
x-litellm-attempted-fallbacks: 1
{"id":"chatcmpl-5477ae61-...","model":"us.anthropic.claude-sonnet-4-6","object":"chat.completion","choices":[{"finish_reason":"stop","index":0,"message":{"content":"391","role":"assistant",...

ARN without base_model

  1. Send the request with "model": "opus48-no-base-model"
  2. Bedrock rejects the rewritten thinking budget
HTTP/1.1 400 Bad Request
{"error":{"message":"litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: \\\"thinking.type.enabled\\\" is not supported for this model. Use \\\"thinking.type.adaptive\\\" and \\\"output_config.effort\\\" to control thinking behavior.\"}...

After (17d4074)

ARN with base_model

  1. Send the request with "model": "opus48"
  2. Opus answers through the ARN deployment with no fallback
HTTP/1.1 200 OK
x-litellm-model-id: opus48-arn
x-litellm-attempted-fallbacks: 0
{"id":"chatcmpl-1e96bc87-...","model":"opus48","object":"chat.completion","choices":[{"finish_reason":"stop","index":0,"message":{"content":"391","role":"assistant"}}],...

ARN without base_model

  1. Send the request with "model": "opus48-no-base-model"
  2. Same 400 as before
HTTP/1.1 400 Bad Request
{"error":{"message":"litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: \\\"thinking.type.enabled\\\" is not supported for this model. Use \\\"thinking.type.adaptive\\\" and \\\"output_config.effort\\\" to control thinking behavior.\"}...
  1. The proxy log now explains how to fix it
LiteLLM:WARNING: converse_transformation.py:1137 - Sending adaptive `thinking` as a fixed thinking budget for model=arn:aws:bedrock:us-east-1:<acct>:application-inference-profile/<profile-id>: an application inference profile ARN does not name its model, so LiteLLM cannot tell whether it supports adaptive thinking. Set `base_model` on the deployment (for example `us.anthropic.claude-opus-4-8`) to send adaptive thinking as requested.

Type

Bug Fix

Caveats (if any)

Medium

  • Bedrock Invoke with an app profile ARN still fails separately
    • Unknown provider=None, tracked outside this PR
  • An ARN without base_model still gets the budget rewrite, now with a warning
  • Router fallbacks can still hide other provider 400s

Note

Medium Risk
Touches core Bedrock Converse request assembly and caching/thinking gates; behavior changes only for application inference profile ARNs when base_model is set, but misconfigured base_model could send wrong params to Bedrock.

Overview
Bedrock application inference profile ARNs do not embed a model id, so LiteLLM was treating them as unknown for Converse capability logic (adaptive thinking, prompt-cache cachePoint blocks, extended TTL, and related param mapping).

This change introduces bedrock_capability_model, which resolves capabilities from the deployment’s base_model (from litellm_params or model_info) when the request model is an app-profile ARN; named model ids are unchanged. Converse sync/async request transforms use that id for thinking and tool behavior while still passing the configured deployment model (deployment_model) into cache-point helpers so per-deployment flags like supports_prompt_cache_breakpoint win over the base model.

bedrock_model_accepts_cache_points and bedrock_cache_point_ttl_supported now consider deployment settings first, then the capability model. The same deployment_model threading applies through message/tool conversion (get_cache_point_block, _bedrock_tools_pt, etc.). map_openai_params for the converse route uses the capability model for mapping. When adaptive thinking is coerced to a fixed budget on an ARN with no base_model, a warning tells operators to set base_model.

Unit tests cover routed profile ARNs for adaptive thinking, disabled thinking, cache points, and the new helper.

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

…ion inference profile ARNs

An application inference profile ARN names no model, so Converse looked up the ARN,
found nothing, and rewrote adaptive thinking to a fixed budget that Opus 4.8 rejects.
Converse now resolves capabilities through the deployment's base_model (model_info or
litellm_params) for these ARNs, and warns when it has to fall back without one.
… types

Keeps the basedpyright gate flat after reading base_model from litellm_params
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@ryan-crabbe-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.

if capped is not None:
optional_params["thinking"] = capped
if is_bedrock_application_inference_profile_arn(model):
litellm.verbose_logger.warning(ADAPTIVE_THINKING_ON_UNRESOLVED_ARN_WARNING, model)
@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_bedrock_arn_adaptive_thinking (9f30b92) with main (e889d9d)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no outstanding actionable findings remain.

Summary

This PR uses base_model to check Bedrock Converse capabilities when an application inference profile ARN hides the model name.

  • Bedrock Converse checks profile capabilities against its base model.
  • Existing Converse tests are easier to scan.

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

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

Checks and execution details
  • Passed · Real testing evidence (required): The rule applies because the PR changes translation in litellm/llms/bedrock/chat/converse_transformation.py. With an app profile ARN plus base_model, the thinking, cache-point, tool-image and output_config gates now run against the base model instead of the ARN.

Manual E2E evidence (PR description): real Bedrock calls in us-east-1 against a temporary application inference profile copied from us.anthropic.claude-opus-4-8. The PR gives the proxy config, the curl command and both commits (merge base 0c91bd7fdb, head 2fae3cadec):

  • ARN with base_model: before, Sonnet answered through the fallback; after, opus48-arn answered with no fallback.
  • ARN without base_model: the same 400 before and after, and the new warning now appears in the proxy log.

Automated tests: new Router-level tests in tests/unit/llms/bedrock/chat/test_converse_transformation.py drive litellm.Router.completion through the real transformation and assert on the outgoing Converse body, covering base_model in both model_info and litellm_params, disabled thinking on always-thinking models, and the no-base_model warning. A further unit test covers bedrock_capability_model.

Result: I ran both test files on the head checkout and got 668 passed.

  • Passed · Bedrock converse + common_utils unit tests (optional): Ran uv run --frozen pytest tests/unit/llms/bedrock/chat/test_converse_transformation.py tests/unit/llms/bedrock/test_bedrock_common_utils.py -n 8.

The first run had 3 failures from ModuleNotFoundError: No module named 'mcp', an environment issue unrelated to this PR. After uv pip install mcp, the rerun gave 668 passed.

  • Passed · Caller trace for capability model (optional): litellm/utils.py passes bedrock_capability_model(model, base_model) into AmazonConverseConfig.map_openai_params. Both _transform_request and _async_transform_request read litellm_params['base_model'] and use the result only for capability gating. The Converse URL still uses the ARN, which the respx route in the new tests confirms. Plain model ids are unaffected: bedrock_capability_model returns model unless the model is an app profile ARN.

View review · Reviewed 2fae3cadecad

@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!

…e_model

An application inference profile ARN that sets supports_prompt_cache_breakpoint keeps that answer, and base_model only decides when the deployment sets nothing
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread litellm/llms/bedrock/common_utils.py Resolved

@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/llms/bedrock/common_utils.py Resolved
… then base_model

Marker support and 1h ttl support now each ask the configured ARN before its base_model, so a deployment override no longer hides the base model's ttl support
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

# Conflicts:
#	litellm/litellm_core_utils/prompt_templates/factory.py
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

Bugbot run

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re 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.

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

@ryan-crabbe-berri
ryan-crabbe-berri enabled auto-merge (squash) October 15, 2026 03:01

@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. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants