fix: pr ammends.

This commit is contained in:
Benedikt Óskarsson 2026-01-19 14:50:57 +00:00
parent f09cae2107
commit 0367e9c9f1
No known key found for this signature in database

View file

@ -55,6 +55,7 @@ from litellm.types.utils import (
)
from litellm.utils import (
add_dummy_tool,
any_assistant_message_has_thinking_blocks,
has_tool_call_blocks,
last_assistant_with_tool_calls_has_no_thinking_blocks,
supports_reasoning,
@ -1077,11 +1078,15 @@ class AmazonConverseConfig(BaseConfig):
# Drop thinking param if thinking is enabled but thinking_blocks are missing
# This prevents the error: "Expected thinking or redacted_thinking, but found tool_use"
#
# IMPORTANT: Only drop thinking if NO assistant messages have thinking_blocks.
# 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 messages is not None
and last_assistant_with_tool_calls_has_no_thinking_blocks(messages)
and not any_assistant_message_has_thinking_blocks(messages)
):
if litellm.modify_params:
optional_params.pop("thinking", None)