From 1d43f14695e97254d4ae56fd4ee4886a8b58a202 Mon Sep 17 00:00:00 2001 From: Vigilans Date: Mon, 13 Apr 2026 17:39:39 +0800 Subject: [PATCH] fix(adapter): drop tool_choice when no regular tools remain (#25477) When all tools are web_search-type and get filtered out, leftover tool_choice causes "tools are required when tool choice is specified" errors from providers. Relates to BerriAI/litellm#25477 --- .../experimental_pass_through/adapters/transformation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index 02e0c562654..5fd22424180 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -1052,6 +1052,9 @@ class LiteLLMAnthropicMessagesAdapter: new_kwargs["web_search_options"] = {} # type: ignore if not regular_tools: + # No regular tools left — drop tool_choice to avoid + # "tools are required when tool choice is specified" errors. + new_kwargs.pop("tool_choice", None) return {} translated_tools, tool_name_mapping = self.translate_anthropic_tools_to_openai(