orq:tool_search tool defers function tools from the prompt until the model asks for them. Mark function tools with defer_loading: true, and the model receives only the search tool plus the non-deferred tools. When the model needs a capability, it searches the deferred tools with a regular expression, and the matching tools become callable on the next turn.
Deferring tools reduces prompt tokens and keeps the tool list stable for prompt caching. It pays off from roughly ten tools or 10k tokens of tool definitions. The search runs on the AI Gateway, so it works with any model that supports tool calling.
Quick start
The examples use the client configuration from the Server tools overview.defer_loading next to function on the tool object.
How it works
- The model sees
orq_tool_searchand the tools that are not deferred. - When it needs a capability, it calls
orq_tool_searchwith a regular expression, for examplecalendar|event. - The AI Gateway matches the pattern case-insensitively against the names, descriptions, and parameter names and descriptions of the deferred tools. A pattern of
weatherfinds a tool whose only mention of weather is in a parameter description. - The matching tools are added to the model’s tool list. The model calls them like any other function tool, and the application handles the call as usual.
previous_response_id or conversation, tools revealed in earlier turns are offered from the start.
Configuration
Set
defer_loading: true on any function tool to hide it. Only function tools can be deferred; orq:tool_search itself is never deferred so the model always has a tool to call.
Rules
- A request with a deferred tool must include
orq:tool_search, otherwise it fails withtool_search_required. tool_choicemust be omitted,auto, ornone. Forcing a tool call conflicts with tool search and fails withtool_choice_conflict.- A pattern is at most 200 characters. A malformed pattern is returned to the model as a tool error, not as a request failure.
- A call to a deferred tool that no search revealed is rejected as a tool that was not offered.
Agents
Agents can use tool search as well. Addorq:tool_search to the agent’s tools and set configuration.defer_loading on the custom tools to hide:
orq:tool_search on the agent, defer_loading has no effect and every tool stays visible.
Cost and usage
Tool searches have no additional charge. The number of searches appears atusage.server_tool_use.tool_search_requests. Each search is an orq:tool_search output item whose result lists the revealed tools.