mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
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:
parent
f48a87ef12
commit
1d43f14695
1 changed files with 3 additions and 0 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue