Gemini's Tool Retrieval: Load Agent Tool Schemas On Demand to Cut Tokens and Latency
For teams integrating hundreds of business endpoints and MCP servers into agents, Tool Retrieval removes the forced trade-off between paying for every schema in every request and building a custom tool-routing layer. It also keeps multi-turn prefix caching intact, which is a key cost control that naive RAG-based tool search tends to break.
Google's new Tool Retrieval feature, now in preview in the Gemini API, tackles the classic agent headache: ballooning input tokens and slower first-token latency when an agent carries dozens or hundreds of tools. Every request used to send full JSON parameter schemas for all tools, even those never used. Tool Retrieval changes that by letting developers mark long-tail tools with `"defer_loading": true` and add `{"type": "tool_search"}` to the request. The model initially sees only names and short descriptions, and loads a full schema only when it decides a tool is relevant, all within a single API request.
The mechanism runs in three logged steps: `tool_search_call`, `tool_search_result`, and the eventual `function_call`. Server-side search is handled by Gemini, so no custom vector index is needed. The approach also preserves prefix caching across multi-turn conversations, because lazily loaded schemas are appended later in the prompt rather than injected into the system prefix. For MCP-heavy setups, marking the `mcp_server` tool with `defer_loading` automatically puts all its sub-tools on demand. An optional `"execution": "client"` mode hands search back to the developer's backend for permission filtering, at the cost of an extra network round-trip.
Pricing stays standard per-token; there's no separate fee. But the savings only materialize when the schemas never used outnumber those actually loaded. Google recommends testing with real traffic. The feature is restricted to the newer Interactions API, only one `tool_search` per request is allowed, and forgetting it alongside `defer_loading` triggers a 400 error. Tool naming and descriptions matter more than before, since the model decides which tools to retrieve based only on those brief hints.
The prefix-caching preservation is the architectural win: unlike naive RAG-based tool search, which mutates the prompt prefix and busts caching, Tool Retrieval keeps the core prefix stable, making it viable even when raw token savings are modest.
The feature is not a universal win; for agents with only a handful of tools or high usage rates of all tools, the fixed cost of `tool_search` and schema re-loading can exceed the savings.
It shifts a non-trivial burden back onto developers: tool retrieval quality now depends on naming and description discipline, so sloppy metadata cancels out the infrastructure benefits.
The client-execution escape hatch acknowledges real enterprise permission requirements, but the added network round-trip per search is a trade-off that may matter for latency-sensitive agents.