fix(adapter): pass allowed_domains through web_search_options to Responses API

When translating Anthropic web_search tools to chat/completions format,
allowed_domains was silently dropped (web_search_options set to {}).
Now extract allowed_domains from the tool and pass it as
filters.allowed_domains in web_search_options, which the Responses API
bridge forwards to the web_search tool.
This commit is contained in:
Vigilans 2026-04-21 21:51:06 +08:00
parent 54eed72ecd
commit fe555bd08f

View file

@ -1049,7 +1049,13 @@ class LiteLLMAnthropicMessagesAdapter:
regular_tools.append(cast(AllAnthropicToolsValues, tool))
if web_search_tools:
new_kwargs["web_search_options"] = {} # type: ignore
web_search_options: Dict[str, Any] = {}
for wst in web_search_tools:
wst_dict = cast(Dict[str, Any], wst)
allowed = wst_dict.get("allowed_domains")
if allowed:
web_search_options.setdefault("filters", {})["allowed_domains"] = allowed
new_kwargs["web_search_options"] = web_search_options # type: ignore
if not regular_tools:
# No regular tools left — drop tool_choice to avoid