litellm/tests/unit/integrations/websearch_interception
JingHao-Leon 3cf5bb2753 fix(websearch_interception): apply allowed_domains / blocked_domains to intercepted searches
With websearch_interception enabled, the Anthropic-native web_search
tool's allowed_domains / blocked_domains were silently dropped: the
tool is replaced by the standard LiteLLM web search tool (which has no
domain fields) and _execute_search() called litellm.asearch() without
search_domain_filter. A /v1/messages request that limited the search
to one domain got results from every domain (issue #44188).

- Pre-call hooks now stash the domain limits on the request kwargs
  before the native tool is replaced (same side-channel pattern as the
  native-blocks flag), and the short-circuit path applies them the
  same way.
- _execute_search() forwards them to litellm.asearch() as
  search_domain_filter: allowed_domains pass through as an allowlist
  and blocked_domains as '-'-prefixed exclusions, the convention
  litellm.asearch's providers (e.g. Perplexity) use.
- _AsearchNamedParams now permits search_domain_filter.
- New unit tests cover extraction, hook stashing, and the asearch
  call wiring.
2026-10-03 01:22:33 +08:00
..
__init__.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_websearch_agentic_loop_cap.py refactor(anthropic): rename experimental_pass_through to pass_through (#43329) 2026-09-26 13:00:50 -07:00
test_websearch_chat_completion.py fix(ci): stop stale CI reds, keep unit tests off the host env, retry CyberArk policy conflicts (#43294) 2026-09-26 09:25:13 -07:00
test_websearch_domain_filters.py fix(websearch_interception): apply allowed_domains / blocked_domains to intercepted searches 2026-10-03 01:22:33 +08:00
test_websearch_interception_handler.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_websearch_interception_thinking.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_websearch_native_blocks.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_websearch_responses.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_websearch_rich_query_shape.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00
test_websearch_short_circuit.py refactor(anthropic): rename experimental_pass_through to pass_through (#43329) 2026-09-26 13:00:50 -07:00
test_websearch_streaming_wrap.py refactor(anthropic): rename experimental_pass_through to pass_through (#43329) 2026-09-26 13:00:50 -07:00
test_websearch_thinking_constraint.py test: move tests/test_litellm integrations and secret_managers into tests/unit (#43194) 2026-09-25 12:57:07 -07:00