A provider's own search runs in its infrastructure and returns citations; a scraper gets a bot challenge after a handful of requests. So each request resolves search from two facts: the session's Search switch (web_search on the session run config) and whether the API provider advertises supports_web_search (_StreamFnProvider, ApiProviderSnapshot).
API
Request tool
Advertised
openai-responses, openai-codex
{"type": "web_search"}
Yes
xAI over openai-responses
The same tool; the local web_search function is left out of the request, because xAI answers 400 “Duplicate tool names” to a function named like its search
{"google_search": {}}, only in a request without function tools
No
DeepSeek, Kimi, local models, OpenAI-compatible endpoints
None
No
With the switch on and the capability advertised, the runtime sets the request option web_search=True and removes the local web_search tool. Otherwise the local tool stays. Gemini's generateContent rejects grounding next to function declarations (Gemini 3 combines them only on the Interactions API) and an agent request always carries function tools; a tool-free completion with web_search=True still uses grounding.
Local tool
Case
Behaviour
Backends
Sixteen, for models without a provider search
No key
Only the DuckDuckGo page scraper
Unpinned fallback
Skips arxiv, a paper index; pinning still reaches it
Every backend fails
The error tells the model a search key fixes it (Settings > Search; Brave and Tavily have free tiers) and that it may open a search page with browser tools if it has them
From provider item to transcript
Stage
Behaviour
Stream
Stream processors turn search items into a ServerToolUse block and servertool_start / servertool_end events.
Agent loop
Forwards them without executing.
Client
tool_use / tool_result with tool: "web_search", provider_executed: true, input{"query": ...}, result one title — url per line, or completed when the provider reports no sources.
Persisted
Same shape in the reply's blocks, so a reloaded transcript shows “Searched the web: …” in place.
Citations
url_citation (Responses), citations (Anthropic), groundingMetadata (Gemini) become citations: [{url, title, start, end}] on TextContent, forwarded with text_end, persisted, rendered as a sources row under the answer.
Replay
Next request goes to
The block
Responses, same API
Resent as a web_search_call item
Anthropic, same API
Resent as server_tool_use plus the raw web_search_tool_result, whose hits carry encrypted_content that must go back verbatim; a block without the raw result is dropped
Gemini
Grounding blocks get synthetic ids and are never resent