Repository navigation
Conversation
… opaque model ids AnthropicModelInfo's adaptive-thinking / always-on-thinking / legacy-thinking capability lookups resolve entirely from the model string (an explicit cost-map entry, or the fallback_generalizations version-regex rule). A Bedrock application inference profile ARN (arn:aws:bedrock:...:application-inference-profile/<id>) carries no "claude" substring and no version number, so every such lookup returns None/False for it — an adaptive-thinking request against a profile-ARN deployment is silently downgraded to legacy thinking.type=enabled, which Claude 5-family models reject with 400 "thinking.type.enabled is not supported". litellm_params.base_model is the existing opaque-id fallback (Azure deployments already use it for model-type detection); this threads it through the same capability-resolution chain so a chart/config pin (model_info.base_model: claude-sonnet-5, or litellm_params.base_model) resolves the correct adaptive-thinking behavior for an ARN the direct lookups can't parse. All new parameters are optional kwargs defaulting to None, so every existing call site (bare 2-3 positional args) is unaffected.
Greptile SummaryThis PR adds base-model fallback capability resolution for opaque Bedrock inference-profile identifiers and propagates it through Converse thinking transformations
Confidence Score: 4/5The capability changes appear correct, but repository requirements must be satisfied by removing the unnecessary comment and adding production-path regression coverage No behavioral failure remains established, but the added test does not protect the new Converse propagation wiring and a changed source comment violates CLAUDE.md Files Needing Attention: litellm/llms/bedrock/chat/converse_transformation.py; tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/common_utils.py | Adds optional base-model fallback across Anthropic adaptive, always-on, legacy, and effort capability helpers |
| litellm/llms/bedrock/chat/converse_transformation.py | Propagates the configured base model through Converse thinking transformations, with one source-comment policy violation |
| litellm/utils.py | Forwards the existing base_model value into Bedrock Converse parameter mapping |
| tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py | Tests helper fallback behavior but does not exercise the production opaque-ARN request-transformation path |
Reviews (1): Last reviewed commit: "fix(bedrock): resolve adaptive-thinking ..." | Re-trigger Greptile
| # Application inference profile ARNs (litellm_params.model) carry no | ||
| # version substring, so the adaptive-thinking capability lookup below | ||
| # resolves nothing for them. litellm_params.base_model is the same | ||
| # opaque-id fallback Azure deployments use for model-type detection — | ||
| # thread it through so a chart/config pin (e.g. base_model: | ||
| # claude-sonnet-5) still gets the right adaptive-thinking behavior. |
There was a problem hiding this comment.
This six-line explanation covers straightforward plumbing and violates CLAUDE.md's source-comment policy, so remove it before merging
| # Application inference profile ARNs (litellm_params.model) carry no | |
| # version substring, so the adaptive-thinking capability lookup below | |
| # resolves nothing for them. litellm_params.base_model is the same | |
| # opaque-id fallback Azure deployments use for model-type detection — | |
| # thread it through so a chart/config pin (e.g. base_model: | |
| # claude-sonnet-5) still gets the right adaptive-thinking behavior. |
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| assert ( | ||
| AnthropicConfig._is_adaptive_thinking_model(opaque_model, "bedrock", base_model="claude-sonnet-5") | ||
| is True | ||
| ) | ||
| assert ( |
There was a problem hiding this comment.
Missing end-to-end regression coverage
This helper-only test still passes if Converse base_model propagation breaks, violating CLAUDE.md's regression-test requirement; production-path coverage is required before merging
Context Used: CLAUDE.md (source)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CI's lint job checks litellm/**/*.py against the changed-files diff with the pinned ruff==0.15.3 formatter; one line in the previous commit exceeded the wrap threshold under that version.
… with BaseConfig CI's basedpyright budget gate flagged reportIncompatibleMethodOverride: adding base_model as a map_openai_params parameter changed its signature away from BaseConfig's abstract declaration, which the repo's strict type-checking budget (ratchet-only, never raised) does not allow. Thread base_model via a declared instance attribute (configured_base_model, set by get_optional_params before the call) instead of a method parameter, so the override signature is unchanged. Every other touched method (_handle_reasoning_effort_parameter, _process_tools_and_beta, _transform_request_helper) is AmazonConverseConfig's own private helper, never declared on BaseConfig, so their added base_model parameters were never an override-compatibility issue.
|
@mateo-berri CI is green and CLA is signed — would appreciate a review when you have a moment. Happy to address any feedback. |
|
Thanks for digging into this. Closing in favor of #46569, which also covers request building and warns when base_model is missing |
What
AnthropicModelInfo's adaptive-thinking / always-on-thinking / legacy-thinking capability lookups (_is_adaptive_thinking_model,_is_always_on_thinking_model,_supports_legacy_thinking) resolve entirely from themodelstring — an explicit cost-map entry, or thefallback_generalizationsversion-regex rule. A Bedrock application inference profile ARN (arn:aws:bedrock:<region>:<account>:application-inference-profile/<id>) carries noclaudesubstring and no version number, so every one of those lookups resolves toNone/Falsefor it.Consequence: an adaptive-thinking request against a profile-ARN deployment is silently downgraded to legacy
thinking.type=enabled, which Claude 5-family models reject with 400thinking.type.enabled is not supported.Fix
litellm_params.base_modelis the existing opaque-model-string fallback (Azure deployments already use it for model-type detection — seeProviderConfigManager.get_provider_chat_config'sbase_modelparam). This PR threads that same fallback through the Anthropic capability-resolution chain:AnthropicModelInfo._supports_model_capability(and its callers_is_adaptive_thinking_model,_is_always_on_thinking_model,_supports_legacy_thinking,maybe_drop_disabled_thinking,translate_legacy_thinking_for_adaptive_model,_legacy_budget_to_effort) now accept an optionalbase_model: str | None = Nonekwarg, retried when the direct lookups onmodelare inconclusive.AmazonConverseConfig.map_openai_paramsand its Bedrock-side helpers (_handle_reasoning_effort_parameter,_process_tools_and_beta,_transform_request_helper) threadbase_modelfromlitellm_params.base_modelthrough to those calls.get_optional_params(litellm/utils.py) passes its existingbase_modelparam intoAmazonConverseConfig().map_openai_params(...)for thebedrock/converseroute.So a chart/config entry like:
now resolves adaptive-thinking correctly, instead of every profile-ARN deployment silently downgrading.
Compatibility
Every new parameter is an optional kwarg defaulting to
None. All existing call sites (which pass 2-3 positional/keyword args) are unaffected — verified by grepping every call site of the touched functions across the codebase.Testing
Added
test_is_adaptive_thinking_model_falls_back_to_base_model_for_opaque_idsintests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py, alongside the existingtest_is_adaptive_thinking_model_is_sourced_from_cost_mapparametrized test it complements.