From f80ca05153db3cceec1127d30385ff96a7402537 Mon Sep 17 00:00:00 2001 From: mateo <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 7 Nov 2026 22:30:28 +0000 Subject: [PATCH] fix(anthropic): avoid duplicate untyped capability reads Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/anthropic/chat/transformation.py | 3 +-- litellm/llms/bedrock/chat/converse_transformation.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index cf7d30fcd71..1b2e1623aa9 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -2518,8 +2518,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): # Anthropic errors with: "When thinking is disabled, an assistant message cannot contain thinking" # Related issue: https://github.com/BerriAI/litellm/issues/18926 if ( - optional_params.get("thinking") is not None - and optional_params.get("thinking") != {"type": "between_tools"} + optional_params.get("thinking") not in (None, {"type": "between_tools"}) and last_assistant_with_tool_calls_has_no_thinking_blocks(capped_messages) and not any_assistant_message_has_thinking_blocks(capped_messages) ): diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 7567fd7fe0f..76bb5a6865b 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -2172,8 +2172,7 @@ class AmazonConverseConfig(BaseConfig): # If any message has thinking_blocks, we must keep thinking enabled, otherwise # Related issues: https://github.com/BerriAI/litellm/issues/14194 if ( - optional_params.get("thinking") is not None - and optional_params.get("thinking") != {"type": "between_tools"} + optional_params.get("thinking") not in (None, {"type": "between_tools"}) and messages is not None and last_assistant_with_tool_calls_has_no_thinking_blocks(messages) and not any_assistant_message_has_thinking_blocks(messages)