fix(anthropic): keep the clear_thinking edit on models that think by default

Sonnet 5, Opus 5, and Haiku 5.5 still think when thinking is left out, so
dropping their clear_thinking edit on effort none only stopped old thinking
from being cleared. A new thinking_on_by_default cost map key marks them,
and both the Python and Rust paths keep the edit for those models.

Python Bedrock Mantle now drops the edit only when LiteLLM dropped thinking
and Bedrock cannot turn it back on, so a client's own edit is forwarded as
before.
This commit is contained in:
mateo-berri 2026-10-29 07:07:39 -07:00
parent 7bb8650140
commit dc172438b9
18 changed files with 193 additions and 28 deletions

View file

@ -122,6 +122,7 @@ mod tests {
"supports_reasoning": true,
"supports_adaptive_thinking": true,
"thinking_always_on": false,
"thinking_on_by_default": true,
"supports_legacy_thinking": false,
"supports_output_config": true,
"supports_sampling_params": false,
@ -144,6 +145,7 @@ mod tests {
supports_reasoning: true,
supports_adaptive_thinking: true,
thinking_always_on: false,
thinking_on_by_default: true,
supports_legacy_thinking: false,
supports_output_config: true,
supports_sampling_params: false,

View file

@ -1880,6 +1880,7 @@ mod tests {
supports_reasoning: false,
supports_adaptive_thinking: false,
thinking_always_on: false,
thinking_on_by_default: false,
supports_legacy_thinking: false,
supports_output_config: false,
supports_sampling_params: true,

View file

@ -184,7 +184,9 @@ fn without_thinking(
params: MessagesOptionalParams,
context: &ThinkingContext,
) -> MessagesOptionalParams {
let context_management = if context.capabilities.thinking_always_on {
let thinks_without_thinking_param =
context.capabilities.thinking_always_on || context.capabilities.thinking_on_by_default;
let context_management = if thinks_without_thinking_param {
params.context_management
} else {
without_clear_thinking_edits(params.context_management)
@ -515,6 +517,14 @@ mod tests {
}
}
#[fixture]
fn sonnet_5() -> MessagesModelCapabilities {
MessagesModelCapabilities {
thinking_on_by_default: true,
..opus_4_7()
}
}
#[fixture]
fn newfamily_6() -> MessagesModelCapabilities {
MessagesModelCapabilities {
@ -716,7 +726,17 @@ mod tests {
serde_json::json!({"max_tokens": 8192, "reasoning_effort": "none"}),
true
)]
fn clear_thinking_edit_is_dropped_with_thinking_except_on_always_on_models(
#[case::default_thinking_model_keeps_edit(
sonnet_5(),
serde_json::json!({"max_tokens": 8192, "reasoning_effort": "none"}),
true
)]
#[case::adaptive_model_without_default_thinking_drops_edit(
opus_4_7(),
serde_json::json!({"max_tokens": 8192, "reasoning_effort": "none"}),
false
)]
fn clear_thinking_edit_is_dropped_with_thinking_except_on_models_that_think_by_default(
#[case] capabilities: MessagesModelCapabilities,
#[case] fields: Value,
#[case] keeps_edit: bool,
@ -726,7 +746,8 @@ mod tests {
"context_management".into(),
serde_json::json!({"edits": [{"type": "clear_thinking_20251015", "keep": "all"}, {"type": "clear_tool_uses_20250919"}]}),
);
let always_on = capabilities.thinking_always_on;
let thinks_without_thinking_param =
capabilities.thinking_always_on || capabilities.thinking_on_by_default;
let translated = serde_json::to_value(translate(capabilities, fields).unwrap()).unwrap();
let edit_types: Vec<&str> = translated["context_management"]["edits"]
.as_array()
@ -742,7 +763,7 @@ mod tests {
assert_eq!(edit_types, expected);
assert_eq!(
translated.get("thinking").is_some(),
keeps_edit && !always_on
keeps_edit && !thinks_without_thinking_param
);
}

View file

@ -32,6 +32,8 @@ pub struct MessagesModelCapabilities {
#[serde(default)]
pub thinking_always_on: bool,
#[serde(default)]
pub thinking_on_by_default: bool,
#[serde(default)]
pub supports_legacy_thinking: bool,
#[serde(default)]
pub supports_output_config: bool,
@ -55,6 +57,7 @@ impl Default for MessagesModelCapabilities {
supports_reasoning: false,
supports_adaptive_thinking: false,
thinking_always_on: false,
thinking_on_by_default: false,
supports_legacy_thinking: false,
supports_output_config: false,
supports_sampling_params: true,

View file

@ -155,6 +155,7 @@ pub struct ModelInfoFields {
pub supports_adaptive_thinking: Option<bool>,
pub supports_legacy_thinking: Option<bool>,
pub thinking_always_on: Option<bool>,
pub thinking_on_by_default: Option<bool>,
pub supports_tool_search: Option<bool>,
pub supports_mid_conversation_system: Option<bool>,
pub supports_anthropic_thinking_payload: Option<bool>,

View file

@ -104,6 +104,7 @@ attributes! {
/// Cloud regions the model is available in ('global' or region ids).
supported_regions: Vec<String>,
thinking_always_on: bool,
thinking_on_by_default: bool,
token_count_framing: u64 as Count,
token_count_model: TokenCountModel,
token_count_tokenizer: TokenCountTokenizer,

View file

@ -1819,8 +1819,12 @@ def drop_clear_thinking_edits_for_model(
model: str,
custom_llm_provider: str,
) -> None:
"""Remove the clear_thinking edits unless the model always thinks anyway."""
if not AnthropicModelInfo.supports_model_capability(model, "thinking_always_on", custom_llm_provider):
"""Remove the clear_thinking edits unless the model still thinks without a ``thinking`` param."""
thinks_without_thinking_param: Final = any(
AnthropicModelInfo.supports_model_capability(model, capability, custom_llm_provider)
for capability in ("thinking_always_on", "thinking_on_by_default")
)
if not thinks_without_thinking_param:
drop_clear_thinking_edits(params)

View file

@ -1,4 +1,4 @@
from collections.abc import Mapping
from collections.abc import Mapping, MutableMapping
from types import MappingProxyType
from typing import Final
@ -46,21 +46,21 @@ class BedrockMantleAnthropicMessagesConfig(BedrockMantleAuthMixin, AmazonMantleM
}
)
def _ensure_thinking_for_clear_thinking_context_management(
def _drop_thinking(
self,
anthropic_messages_request: dict[str, object], # mutable-ok: edits the request in place like the base
optional_params: MutableMapping[str, object], # mutable-ok: edits optional params in place
model: str,
drop_params: bool,
) -> bool:
injected_thinking: Final = super()._ensure_thinking_for_clear_thinking_context_management(
anthropic_messages_request, model, drop_params
)
match anthropic_messages_request.get("thinking"):
case {"type": "enabled" | "adaptive"}:
pass
case _:
drop_clear_thinking_edits_for_model(anthropic_messages_request, model, self._resolved_provider)
return injected_thinking
custom_llm_provider: str,
) -> None:
super()._drop_thinking(optional_params, model, custom_llm_provider)
if not self._adds_thinking_back_for_clear_thinking(optional_params, model):
drop_clear_thinking_edits_for_model(optional_params, model, custom_llm_provider)
def _adds_thinking_back_for_clear_thinking(self, optional_params: Mapping[str, object], model: str) -> bool:
trial_request: Final = {
key: optional_params[key] for key in ("context_management", "max_tokens") if key in optional_params
}
return self._ensure_thinking_for_clear_thinking_context_management(trial_request, model, drop_params=False)
def __init__(self, aws_signer: BaseAWSLLM | None = None) -> None:
AmazonMantleMessagesConfig.__init__(self)

View file

@ -1939,6 +1939,7 @@
"anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
@ -2025,6 +2026,7 @@
"global.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
@ -2111,6 +2113,7 @@
"us.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2197,6 +2200,7 @@
"eu.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2278,6 +2282,7 @@
"au.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2364,6 +2369,7 @@
"jp.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2760,6 +2766,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2804,6 +2811,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2848,6 +2856,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2892,6 +2901,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2936,6 +2946,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2980,6 +2991,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -3827,6 +3839,7 @@
"deprecation_date": "2027-07-08",
"supports_mid_conversation_system": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
@ -3964,6 +3977,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -15928,6 +15942,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -16461,6 +16476,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -21268,6 +21284,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_function_calling": true,
"supports_mid_conversation_system": true,
@ -21425,6 +21442,7 @@
"prompt_cache_min_tokens": 1024,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_function_calling": true,
"supports_mid_conversation_system": true,
@ -32864,6 +32882,7 @@
"/v1/messages"
],
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_reasoning": true,
@ -32931,6 +32950,7 @@
"/v1/messages"
],
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_reasoning": true,
@ -32974,6 +32994,7 @@
"/v1/messages"
],
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_reasoning": true,
@ -49051,6 +49072,7 @@
"prompt_cache_min_tokens": 1024,
"source": "https://aws.amazon.com/bedrock/pricing/",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -49128,6 +49150,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://aws.amazon.com/bedrock/pricing/",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -51528,6 +51551,7 @@
"regional_endpoint_uplift_multiplier": 1.1,
"supports_mid_conversation_system": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
"cache_creation_input_token_cost_batches": 3.125e-06,
@ -51566,6 +51590,7 @@
"regional_endpoint_uplift_multiplier": 1.1,
"supports_mid_conversation_system": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
"cache_creation_input_token_cost_batches": 3.125e-06,
@ -51809,6 +51834,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -59133,6 +59159,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -65209,6 +65236,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://deepinfra.com/pricing",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_response_schema": true,
@ -65524,6 +65552,7 @@
"prompt_cache_min_tokens": 1024,
"source": "https://deepinfra.com/pricing",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_response_schema": true,
@ -67521,6 +67550,7 @@
"output_cost_per_token": 1.2e-05,
"prompt_cache_min_tokens": 1024,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -67596,6 +67626,7 @@
"output_cost_per_token": 3e-05,
"prompt_cache_min_tokens": 512,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -67809,6 +67840,7 @@
"output_cost_per_token": 1.2e-05,
"prompt_cache_min_tokens": 1024,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -67874,6 +67906,7 @@
"output_cost_per_token": 3e-05,
"prompt_cache_min_tokens": 512,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -68711,6 +68744,7 @@
"litellm_provider": "perplexity",
"mode": "responses",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"prompt_cache_min_tokens": 512,
"supports_web_search": true,
"supports_function_calling": true,
@ -68734,6 +68768,7 @@
"litellm_provider": "perplexity",
"mode": "responses",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_web_search": true,
"supports_function_calling": true,
"input_cost_per_token": 2e-06,
@ -70810,6 +70845,7 @@
"supports_vision": true,
"supports_web_search": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"prompt_cache_min_tokens": 512,
"supports_sampling_params": false
},
@ -70830,6 +70866,7 @@
"supports_vision": true,
"prompt_cache_min_tokens": 1024,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_sampling_params": false
},
"aihubmix/coding-glm-5.3": {
@ -73453,6 +73490,7 @@
"apac.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"litellm_provider": "bedrock_converse",
"supports_tool_search": true,
@ -73567,6 +73605,7 @@
"max_output_tokens": 128000,
"mode": "chat",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75054,6 +75093,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75106,6 +75146,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75150,6 +75191,7 @@
"thinking_always_on": false,
"prompt_cache_min_tokens": 512,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75197,6 +75239,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75233,6 +75276,7 @@
"max_output_tokens": 128000,
"mode": "chat",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75289,6 +75333,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75335,6 +75380,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75375,6 +75421,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrockFoundationModels/current/index.json",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75416,6 +75463,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrockFoundationModels/current/index.json",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75462,6 +75510,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75513,6 +75562,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75559,6 +75609,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75586,6 +75637,7 @@
"litellm_provider": "perplexity",
"mode": "responses",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_web_search": true,
"supports_function_calling": true,
"input_cost_per_token": 1e-07,
@ -75616,6 +75668,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrockFoundationModels/current/index.json",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75667,6 +75720,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75717,6 +75771,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75761,6 +75816,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -77516,6 +77572,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -77730,6 +77787,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -77894,6 +77952,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -78362,6 +78421,7 @@
"prompt_cache_min_tokens": 512.0,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_anthropic_thinking_payload": true,
"supports_assistant_prefill": false,
"supports_function_calling": true,

View file

@ -27,6 +27,7 @@ def anthropic_model_capabilities(model: str, custom_llm_provider: str | None) ->
"supports_reasoning": supports("supports_reasoning"),
"supports_adaptive_thinking": supports("supports_adaptive_thinking"),
"thinking_always_on": supports("thinking_always_on"),
"thinking_on_by_default": supports("thinking_on_by_default"),
"supports_legacy_thinking": supports("supports_legacy_thinking"),
"supports_output_config": supports("supports_output_config"),
"supports_sampling_params": AnthropicModelInfo._supports_sampling_params(resolved_model), # pyright: ignore[reportPrivateUsage] # same gate the handler applies

View file

@ -216,6 +216,7 @@ class ProviderSpecificModelInfo(TypedDict, total=False):
supports_adaptive_thinking: bool | None
supports_legacy_thinking: ReadOnly[bool | None]
thinking_always_on: ReadOnly[bool | None]
thinking_on_by_default: ReadOnly[bool | None]
supports_tool_search: bool | None
supports_mid_conversation_system: bool | None
supports_url_context: bool | None

View file

@ -7022,6 +7022,7 @@ def get_model_info_helper(
supports_adaptive_thinking=_model_info.get("supports_adaptive_thinking", None),
supports_legacy_thinking=_model_info.get("supports_legacy_thinking", None),
thinking_always_on=_model_info.get("thinking_always_on", None),
thinking_on_by_default=_model_info.get("thinking_on_by_default", None),
supports_tool_search=_model_info.get("supports_tool_search", None),
supports_mid_conversation_system=_model_info.get("supports_mid_conversation_system", None),
supports_anthropic_thinking_payload=_model_info.get("supports_anthropic_thinking_payload", None),

View file

@ -1939,6 +1939,7 @@
"anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
@ -2025,6 +2026,7 @@
"global.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
@ -2111,6 +2113,7 @@
"us.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2197,6 +2200,7 @@
"eu.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2278,6 +2282,7 @@
"au.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2364,6 +2369,7 @@
"jp.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"cache_creation_input_token_cost": 6.875e-06,
"cache_creation_input_token_cost_above_1hr": 1.1e-05,
@ -2760,6 +2766,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2804,6 +2811,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2848,6 +2856,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2892,6 +2901,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2936,6 +2946,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -2980,6 +2991,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -3827,6 +3839,7 @@
"deprecation_date": "2027-07-08",
"supports_mid_conversation_system": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
@ -3964,6 +3977,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -15928,6 +15942,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -16461,6 +16476,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -21268,6 +21284,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_function_calling": true,
"supports_mid_conversation_system": true,
@ -21425,6 +21442,7 @@
"prompt_cache_min_tokens": 1024,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_function_calling": true,
"supports_mid_conversation_system": true,
@ -32864,6 +32882,7 @@
"/v1/messages"
],
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_reasoning": true,
@ -32931,6 +32950,7 @@
"/v1/messages"
],
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_reasoning": true,
@ -32974,6 +32994,7 @@
"/v1/messages"
],
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_parallel_function_calling": true,
"supports_reasoning": true,
@ -49051,6 +49072,7 @@
"prompt_cache_min_tokens": 1024,
"source": "https://aws.amazon.com/bedrock/pricing/",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -49128,6 +49150,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://aws.amazon.com/bedrock/pricing/",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -51528,6 +51551,7 @@
"regional_endpoint_uplift_multiplier": 1.1,
"supports_mid_conversation_system": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
"cache_creation_input_token_cost_batches": 3.125e-06,
@ -51566,6 +51590,7 @@
"regional_endpoint_uplift_multiplier": 1.1,
"supports_mid_conversation_system": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"cache_creation_input_token_cost": 6.25e-06,
"cache_creation_input_token_cost_above_1hr": 1e-05,
"cache_creation_input_token_cost_batches": 3.125e-06,
@ -51809,6 +51834,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -59133,6 +59159,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -65209,6 +65236,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://deepinfra.com/pricing",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_response_schema": true,
@ -65524,6 +65552,7 @@
"prompt_cache_min_tokens": 1024,
"source": "https://deepinfra.com/pricing",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_response_schema": true,
@ -67521,6 +67550,7 @@
"output_cost_per_token": 1.2e-05,
"prompt_cache_min_tokens": 1024,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -67596,6 +67626,7 @@
"output_cost_per_token": 3e-05,
"prompt_cache_min_tokens": 512,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -67809,6 +67840,7 @@
"output_cost_per_token": 1.2e-05,
"prompt_cache_min_tokens": 1024,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -67874,6 +67906,7 @@
"output_cost_per_token": 3e-05,
"prompt_cache_min_tokens": 512,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -68711,6 +68744,7 @@
"litellm_provider": "perplexity",
"mode": "responses",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"prompt_cache_min_tokens": 512,
"supports_web_search": true,
"supports_function_calling": true,
@ -68734,6 +68768,7 @@
"litellm_provider": "perplexity",
"mode": "responses",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_web_search": true,
"supports_function_calling": true,
"input_cost_per_token": 2e-06,
@ -70810,6 +70845,7 @@
"supports_vision": true,
"supports_web_search": true,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"prompt_cache_min_tokens": 512,
"supports_sampling_params": false
},
@ -70830,6 +70866,7 @@
"supports_vision": true,
"prompt_cache_min_tokens": 1024,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_sampling_params": false
},
"aihubmix/coding-glm-5.3": {
@ -73453,6 +73490,7 @@
"apac.anthropic.claude-opus-5": {
"bedrock_converse_supports_strict_tools": false,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"litellm_provider": "bedrock_converse",
"supports_tool_search": true,
@ -73567,6 +73605,7 @@
"max_output_tokens": 128000,
"mode": "chat",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75054,6 +75093,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75106,6 +75146,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75150,6 +75191,7 @@
"thinking_always_on": false,
"prompt_cache_min_tokens": 512,
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75197,6 +75239,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75233,6 +75276,7 @@
"max_output_tokens": 128000,
"mode": "chat",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75289,6 +75333,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75335,6 +75380,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75375,6 +75421,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrockFoundationModels/current/index.json",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75416,6 +75463,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrockFoundationModels/current/index.json",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75462,6 +75510,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75513,6 +75562,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75559,6 +75609,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75586,6 +75637,7 @@
"litellm_provider": "perplexity",
"mode": "responses",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_web_search": true,
"supports_function_calling": true,
"input_cost_per_token": 1e-07,
@ -75616,6 +75668,7 @@
"prompt_cache_min_tokens": 512,
"source": "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrockFoundationModels/current/index.json",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75667,6 +75720,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -75717,6 +75771,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -75761,6 +75816,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@ -77516,6 +77572,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -77730,6 +77787,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -77894,6 +77952,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
@ -78362,6 +78421,7 @@
"prompt_cache_min_tokens": 512.0,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_adaptive_thinking": true,
"thinking_on_by_default": true,
"supports_anthropic_thinking_payload": true,
"supports_assistant_prefill": false,
"supports_function_calling": true,

View file

@ -363,11 +363,12 @@ CLEAR_TOOL_USES_EDIT: Final = {"type": "clear_tool_uses_20250919"}
pytest.param("claude-sonnet-4-6", _claude_code_payload(effort="high"), True, id="adaptive-model"),
pytest.param("claude-3-5-haiku-latest", _claude_code_payload(), False, id="non-reasoning-model"),
pytest.param("claude-haiku-4-5", _claude_code_payload(), True, id="legacy-thinking-model"),
pytest.param(
"claude-opus-4-8", {"reasoning_effort": "none"}, False, id="adaptive-model-without-default-thinking"
),
],
)
def test_clear_thinking_edit_dropped_exactly_when_thinking_is(model, params, keeps_thinking):
"""Anthropic rejects a clear_thinking edit without thinking, so every path that drops
thinking must drop the edit too, and leave other edits alone"""
result = _transform(
model,
{
@ -382,10 +383,10 @@ def test_clear_thinking_edit_dropped_exactly_when_thinking_is(model, params, kee
assert result["context_management"] == {"edits": expected_edits}
def test_clear_thinking_edit_kept_for_always_on_thinking_model_without_thinking():
"""An always-on model keeps thinking adaptively after reasoning_effort='none' drops the param"""
@pytest.mark.parametrize("model", ["claude-fable-5", "claude-sonnet-5", "claude-opus-5", "claude-haiku-5-5"])
def test_clear_thinking_edit_kept_when_model_thinks_without_thinking_param(model):
result = _transform(
"claude-fable-5",
model,
{"max_tokens": 8192, "reasoning_effort": "none", "context_management": {"edits": [CLEAR_THINKING_EDIT]}},
)

View file

@ -2203,8 +2203,6 @@ def test_bedrock_invoke_transform_emits_adaptive_thinking_for_opus_4_8():
],
)
def test_bedrock_invoke_keeps_thinking_for_clear_thinking_edit_when_base_drops_thinking(thinking_params):
"""The base messages transform drops thinking for Opus 4.5 here. Bedrock keeps the
clear_thinking edit long enough to add the minimum enabled thinking back, then strips it"""
from litellm.types.router import GenericLiteLLMParams
result = AmazonAnthropicClaudeMessagesConfig().transform_anthropic_messages_request(

View file

@ -235,6 +235,13 @@ class TestRequestBody:
["clear_tool_uses_20250919"],
id="no-thinking-support-drops-edit",
),
pytest.param(
"anthropic.claude-3-5-haiku-20241022-v1:0",
{},
None,
["clear_thinking_20251015", "clear_tool_uses_20250919"],
id="caller-edit-without-thinking-forwarded",
),
pytest.param(
"anthropic.claude-opus-4-5-20251101-v1:0",
{"thinking": {"type": "adaptive"}, "output_config": {"effort": "high"}},
@ -258,7 +265,7 @@ class TestRequestBody:
),
],
)
def test_clear_thinking_edit_forwarded_only_with_thinking(
def test_clear_thinking_edit_dropped_only_with_dropped_thinking(
self, model, thinking_params, expected_thinking, expected_edit_types
):
body = BedrockMantleAnthropicMessagesConfig().transform_anthropic_messages_request(

View file

@ -60,6 +60,7 @@ class _CopilotThinkingCapabilities(BaseModel):
supports_adaptive_thinking: bool | None = None
supports_legacy_thinking: bool | None = None
thinking_always_on: bool | None = None
thinking_on_by_default: bool | None = None
def _copilot_endpoint_rows(path: Path) -> Mapping[str, _CopilotEndpointRow]:
@ -87,6 +88,7 @@ _THINKING_KEYS: Final[tuple[str, ...]] = (
"supports_adaptive_thinking",
"supports_legacy_thinking",
"thinking_always_on",
"thinking_on_by_default",
)

View file

@ -1205,6 +1205,7 @@ _COST_MAP_ROW_SCHEMA: Final = {
"supports_anthropic_thinking_payload": {"type": "boolean"},
"supports_legacy_thinking": {"type": "boolean"},
"thinking_always_on": {"type": "boolean"},
"thinking_on_by_default": {"type": "boolean"},
"supports_mid_conversation_system": {"type": "boolean"},
"supports_sampling_params": {"type": "boolean"},
"supports_output_config": {"type": "boolean"},