# `AshAi.ToolSearch`
[🔗](https://github.com/ash-project/ash_ai/blob/v1.5.6/lib/ash_ai/tool_search.ex#L6)

Deferred tool loading for `AshAi.ToolLoop`, using the provider's own tool
search.

With `tool_search` enabled, deferred tools are sent marked `defer_loading`
along with the provider's hosted search tool (Anthropic's
`tool_search_tool_bm25`, or OpenAI's `tool_search` on the Responses API,
gpt-5.4 and later). The provider keeps deferred tools out of the model's
context until the model searches for them, and out of the cached prompt
prefix, so loading one doesn't invalidate the cache.

The provider's built-in search is the only strategy for now. With any other
provider, tool search is skipped and every tool is sent normally. Other
strategies may be added later.

## Options

- `:defer` - which tools to defer: `:all` (default), a list of tool names,
  or a function that takes a `ReqLLM.Tool` and returns a boolean.
- `:always_load` - tool names that are never deferred.

# `new`

Prepares tool search for a loop.

Returns `nil` when tool search is disabled, the model's provider has no
built-in search, or nothing is deferred.

# `request_opts`

ReqLLM options for each request: adds Anthropic's hosted search tool.

# `request_tools`

The tools to send on each request.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
