Repository navigation
Conversation
WebToolProvider(exclude_domains=[...]) removes the listed domains, subdomains included, from web_search results. Without the argument the comma-separated WEB_SEARCH_EXCLUDE_DOMAINS environment variable is used, so default_tools() benchmark runs can turn it on without code changes. Brave has no exclude_domains parameter, so the domains are sent as one inline Goggle with a `$discard,site=<domain>` rule each. Brave does not document whether site= covers subdomains, so results from an excluded host are also dropped client-side and counted in WebSearchMetadata.results_excluded. Entries are restricted to hostname characters so they cannot inject Goggle rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Search benchmarks need some sites kept out of the agent's search results, usually the site hosting the benchmark's questions and answers. This adds that option to
web_search:or, so it also applies to
default_tools()without code changes:huggingface.cocoversdiscuss.huggingface.co).*.is accepted. Anything that is not a hostname raisesValueError.exclude_domainsreplaces the env var;exclude_domains=[]turns it off.web_searchis filtered.fetch_web_pagecan still open a URL on an excluded domain (see below).How it maps to Brave
Brave Search has no
exclude_domainsparameter. The Goggles docs say domains are removed with$discard,site=<domain>rules, sent inline in thegogglesquery parameter, one rule per line. The tool sends one inline Goggle with a rule per domain.Brave does not say whether
site=matches subdomains. So the tool also drops any returned result whose host is an excluded domain or one of its subdomains, and counts those in the newWebSearchMetadata.results_excluded. A search can therefore return fewer than 5 results. A non-zeroresults_excludedalso shows when the server-side rule let something through.Domains are written into Goggle rules, so entries are limited to hostname characters. Otherwise an entry like
"a.com\n$discard"would inject a generic rule that discards every result.Naming in other search APIs
I checked the docs of the other common search APIs. The feature is the same everywhere but the parameter name differs. The table is also in
docs/api/tools/web.mdas the mapping to use when another provider is added:goggleswith$discard,site=<domain>rulesexclude_domainsexcludeDomainssource_policy.exclude_domainssearch_domain_filter, each domain prefixed with-blocked_domainsfilters.blocked_domainsexclude_domainsNot in this PR
fetch_web_pageis not restricted. An agent that already knows a URL on an excluded domain can still open it. Blocking fetches as well is a small follow-up if benchmark runs need it.Testing
tests/test_web_search.py(mocked Brave transport): the Goggle request parameter, normalization and de-duplication, client-side removal of subdomain matches (and no false matches onnothuggingface.coor on the URL path), metadata aggregation, rejection of invalid or injecting entries, the env var fallback, and[]overriding the env var.pytest -m "not docker and not e2b and not browser"(without the model-speed and MCP smoke tests): 382 passed.ruff format --check,ruff checkandty checkare clean.goggles=$discard,site=...removes the domain would be worthwhile.🤖 Generated with Claude Code