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
This commit is contained in:
Vigilans 2026-04-13 17:39:39 +08:00
parent f48a87ef12
commit 1d43f14695

View file

@ -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(