Summary
GoogleModel discards WebSearchTool.blocked_domains. The google-genai SDK now
has a field for it — GoogleSearch.exclude_domains — so the mapping is available
but not wired up.
This is the GoogleModel row of the matrix in #6156. That issue was closed after
the Groq row was fixed (_get_native_tools now builds search_settings with
include_domains / exclude_domains); the Google row was left as-is.
Reproduction
Network-free — a MockTransport captures the outgoing body, so no API key is needed.
Verified on pydantic-ai-slim[google]==2.40.0 / google-genai==2.22.0.
import asyncio, json, httpx
from google.genai import Client
from google.genai.types import HttpOptions
from pydantic_ai import WebSearchTool
from pydantic_ai.messages import ModelRequest, UserPromptPart
from pydantic_ai.models import ModelRequestParameters
from pydantic_ai.models.google import GoogleModel
from pydantic_ai.providers.google import GoogleProvider
captured = {}
CANNED = {
'candidates': [{'content': {'role': 'model', 'parts': [{'text': 'ok'}]}, 'finishReason': 'STOP'}],
'usageMetadata': {'promptTokenCount': 1, 'candidatesTokenCount': 1, 'totalTokenCount': 2},
'modelVersion': 'gemini-3.7-flash',
}
async def handler(request: httpx.Request) -> httpx.Response:
captured['body'] = json.loads(request.content)
return httpx.Response(200, json=CANNED)
async def main():
client = Client(
api_key='not-a-real-key',
http_options=HttpOptions(async_client_args={'transport': httpx.MockTransport(handler)}),
)
model = GoogleModel('gemini-3.7-flash', provider=GoogleProvider(client=client))
await model.request(
[ModelRequest(parts=[UserPromptPart(content='hi')])],
None,
ModelRequestParameters(native_tools=[WebSearchTool(blocked_domains=['example.com'])]),
)
print('sent:', json.dumps(captured['body']['tools']))
asyncio.run(main())
Output:
sent: [{"googleSearch": {}}]
blocked_domains is gone, with no error and no warning.
Cause
models/google.py:744 constructs the tool with no arguments:
if isinstance(tool, WebSearchTool):
tools.append(ToolDict(google_search=GoogleSearchDict()))
The SDK field exists
>>> from google.genai.types import GoogleSearch
>>> list(GoogleSearch.model_fields)
['search_types', 'blocking_confidence', 'exclude_domains', 'time_range_filter']
>>> GoogleSearch(exclude_domains=['example.com']).model_dump(exclude_none=True)
{'exclude_domains': ['example.com']}
So blocked_domains → exclude_domains is a direct mapping, the same shape as the
Groq fix in #6156.
Suggested fix (sketch)
if isinstance(tool, WebSearchTool):
google_search = GoogleSearchDict()
if tool.blocked_domains is not None:
google_search['exclude_domains'] = tool.blocked_domains
tools.append(ToolDict(google_search=google_search))
and add Google to the WebSearchTool.blocked_domains docstring's "Supported by" list.
Note allowed_domains has no Google equivalent — GoogleSearch only offers the
exclude side — so that one stays unsupported.
Out of scope (checked, not asking for these)
max_uses — documented as ignored ("Other native providers ignore it"), and
GoogleSearch has no equivalent knob. Working as intended.
- Vertex + Gemini 3 grounding — the
include_server_side_tool_invocations parameter is not supported in Vertex AI
ValueError is already fixed on main by the not self._is_google_cloud guard.
Mentioned only so it is not re-reported.
Summary
GoogleModeldiscardsWebSearchTool.blocked_domains. Thegoogle-genaiSDK nowhas a field for it —
GoogleSearch.exclude_domains— so the mapping is availablebut not wired up.
This is the
GoogleModelrow of the matrix in #6156. That issue was closed afterthe Groq row was fixed (
_get_native_toolsnow buildssearch_settingswithinclude_domains/exclude_domains); the Google row was left as-is.Reproduction
Network-free — a
MockTransportcaptures the outgoing body, so no API key is needed.Verified on
pydantic-ai-slim[google]==2.40.0/google-genai==2.22.0.Output:
blocked_domainsis gone, with no error and no warning.Cause
models/google.py:744constructs the tool with no arguments:The SDK field exists
So
blocked_domains→exclude_domainsis a direct mapping, the same shape as theGroq fix in #6156.
Suggested fix (sketch)
and add Google to the
WebSearchTool.blocked_domainsdocstring's "Supported by" list.Note
allowed_domainshas no Google equivalent —GoogleSearchonly offers theexclude side — so that one stays unsupported.
Out of scope (checked, not asking for these)
max_uses— documented as ignored ("Other native providers ignore it"), andGoogleSearchhas no equivalent knob. Working as intended.include_server_side_tool_invocations parameter is not supported in Vertex AIValueErroris already fixed onmainby thenot self._is_google_cloudguard.Mentioned only so it is not re-reported.