OpenProgram Docs

Web search

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).

APIRequest toolAdvertised
openai-responses, openai-codex{"type": "web_search"}Yes
xAI over openai-responsesThe 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 searchYes
anthropic-messages{"type": "web_search_20250305", "name": "web_search"}Yes
google-generative-ai, gemini-subscription{"google_search": {}}, only in a request without function toolsNo
DeepSeek, Kimi, local models, OpenAI-compatible endpointsNoneNo

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

CaseBehaviour
BackendsSixteen, for models without a provider search
No keyOnly the DuckDuckGo page scraper
Unpinned fallbackSkips arxiv, a paper index; pinning still reaches it
Every backend failsThe 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

StageBehaviour
StreamStream processors turn search items into a ServerToolUse block and servertool_start / servertool_end events.
Agent loopForwards them without executing.
Clienttool_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.
PersistedSame shape in the reply's blocks, so a reloaded transcript shows “Searched the web: …” in place.
Citationsurl_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 toThe block
Responses, same APIResent as a web_search_call item
Anthropic, same APIResent 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
GeminiGrounding blocks get synthetic ids and are never resent
A different APIDropped, like foreign thinking signatures
Wire contract

Content block, openprogram/models/providers/types.py:

class ServerToolUse(BaseModel):
    type: Literal["serverToolUse"] = "serverToolUse"
    id: str                 # provider item id
    name: str               # "web_search"
    input: dict             # {"query": str}
    status: str             # "searching" | "completed" | "failed"
    results: list[dict]     # [{"title": str, "url": str}]
    raw: Any | None = None  # provider item, for replay
NameShape
Text blockTextContent.citations: list[Citation] | None, Citation(url, title, start, end)
Message eventsEventServerToolStart(type="servertool_start", content_index, partial), EventServerToolEnd(type="servertool_end", content_index, server_tool: ServerToolUse, partial)
Client eventsapps/web/lib/net/ws/chat-stream.ts: citations on the text block at text_end; the search block arrives in the reply row of a transcript_update
Persisted block{"type": "tool", "tool": "web_search", "provider_executed": true, "input": "{\"query\": ...}", "result": ...}
What comes from other agents
AgentIts searchTaken
Claude CodeProvider web_search server tool, results with citationsProvider tool first, citations on the text
Codex--search enables the Responses tool; one “Searched the web: query” line per searchOne visible step per search
Gemini CLIgoogle_web_search is grounding; numbered sources at the endA sources row under the answer
OpenProgram addsThe local tool, and a session-level switch that follows the session's model

Implementation status

AreaState
Capability flagopenai-responses, openai-codex, anthropic-messages
Request buildersAll five APIs
Stream processingResponses (shared processor), Anthropic, Gemini
RuntimeIntent to request option, local tool removal, event projection, persistence, local tool error text and fallback order
ClientProvider-executed search cards and citation rows
Last updated · 2026-11-25