Skip to main content

Module web_search

Module web_search 

Source
Expand description

web_search: search the web and return the top results as numbered sources.

Three modes serve the web_search built-in (WebSearchSetting):

  • native: a provider server tool on the model itself (Anthropic web_search, the OpenAI Responses web_search tool, Bedrock Mantle’s GPT models), with no harness tool. The tool records for those are anthropic_web_search_tool, openai_web_search_tool and bedrock_mantle_web_search_tool;
  • AgentCore (features bedrock or mantle): on Bedrock models without native search, the make_agent_core_web_search tool built here, backed by Amazon Bedrock AgentCore’s InvokeWebSearch API and authorized by IAM;
  • Exa (opt-in, feature mcp): the web_search_tool built here, backed by Exa’s hosted MCP server, a third party that receives the queries. The keyless tier works out of the box and EXA_API_KEY lifts its rate limit.

The tool/backend split (search_tool over a SearchBackend) keeps the model-facing contract fixed while the provider behind it can change.

Structs§

AgentCoreBackend
The search backend over AgentCore web search (agentCoreBackend). A missing permission, missing credentials, or an unsupported region is permanent, so it is remembered (and logged once) and later searches fail without a request.
ExaBackend
The search backend over Exa’s hosted MCP server. Each search opens its own MCP session and closes it.
MakeAgentCoreWebSearchOptions
Options for make_agent_core_web_search (MakeAgentCoreWebSearchOptions).
SearchResult
One search result (SearchResult).
WebSearchError
A backend failure with a message the model can act on (WebSearchError).

Enums§

WebSearchSetting
The web_search built-in setting (WebSearchSetting): on (native search where the model has it), off, or Exa on any model. JSON form: true, false or "exa".

Constants§

WEB_SEARCH_DESCRIPTION
The web_search tool description.

Traits§

SearchBackend
Runs a search (SearchBackend): the top max_results results for query.

Functions§

anthropic_web_search_tool
The Anthropic server tool record for native search (ANTHROPIC_WEB_SEARCH), for AnthropicModelConfig anthropic_tools.
bedrock_mantle_web_search_tool
The Bedrock Mantle (GPT models) built-in tool for native search, for the model’s params.tools.
make_agent_core_web_search
Builds a web_search tool over Amazon Bedrock AgentCore web search (makeAgentCoreWebSearch). The credentials need bedrock-agentcore:InvokeWebSearch.
openai_web_search_tool
The OpenAI Responses built-in tool for native search, for the model’s params.tools.
search_tool
Builds a web_search tool that formats backend’s results as a numbered Sources: list. max_results is clamped to 1-10 (5 when omitted); failures and empty results come back as text.
web_search_tool
The web_search tool served by Exa; EXA_API_KEY is read on every call. The harness builds it when web_search is set to WebSearchSetting::Exa.