AshAi.ToolSearch (ash_ai v1.5.6)

Copy Markdown View Source

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.

Summary

Functions

Prepares tool search for a loop.

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

The tools to send on each request.

Functions

new(tools, config, model)

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(arg1, req_llm_opts)

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

request_tools(search, tools)

The tools to send on each request.