> ## Content Index
> Fetch the complete content index at: https://globalfeed.ai/llms.txt
> Use this file to discover other available public pages before exploring further.

# Your agent has 50 tools and needs one: how does Gemini API's Tool Retrieval work?
- URL: https://globalfeed.ai/en/your-agent-has-50-tools-and-needs-one-how-does-gemini-apis-tool-retrieval-work/
- Published: 2026-11-21T20:07:54.000Z
- Updated: 2026-11-21T20:07:54.000Z
- Description: Google added Tool Retrieval to the Gemini API in preview, loading tool schemas only when needed. How to turn it on, server versus client side, rules and pricing.
- Author: GlobalFeed Editor
- Tags: Gemini, Google, Gemini API, AI Agents, MCP, dil-en, elle

As AI agents grow, so does their tool list: calendar, email, payments, refunds, inventory, search and dozens of connectors. Each tool is introduced to the model with a schema, and those schemas are sent again on every request. On November 19, Google added a feature to the Gemini API to lighten that load: Tool Retrieval. It is in preview for now and works only in the Interactions API.

The idea is simple: the agent keeps its whole tool library at hand but loads the detailed definitions only when the current task needs them. Google's [announcement](https://blog.google/innovation-and-ai/technology/developers-tools/gemini-api-tool-retrieval/?ref=globalfeed.ai) and [developer guide](https://ai.google.dev/gemini-api/docs/tool-retrieval?ref=globalfeed.ai) explain the method with sample code. This article walks through what it is for, how it works and how to try it.

## The problem: the whole library on every request

To give a model a tool, you send a definition with its name, description and parameters, meaning which fields it takes and which are required. According to Google's guide, a few dozen function declarations can take up tens of thousands of tokens on every request. That has two costs: input tokens and latency go up, and tool-selection accuracy falls as the candidate list grows. It is like piling the table of contents of every book in a library onto the desk for each question.

Tool Retrieval shrinks that pile. The model sees only the name and description of each deferred tool, so it knows what is available, while the parameter schemas stay out of context. When the model needs a tool, it asks for it by name, the API loads the full schema and the model calls the function. Google says all three steps happen inside the same API request.

## How to turn it on

Two changes are enough. You add a tool of type `{"type": "tool_search"}` to the tools array and mark each tool you want to hold back with `"defer_loading": true`. In Google's example, a customer service agent is set up with more than 50 deferred functions; when the user says "Order A-1042 arrived damaged, please refund 40 dollars", the model searches for the refund tool, gets its schema and prepares the call with the order number and amount. Google recommends leaving frequently used tools loaded up front and deferring the long tail.

The response shows three steps: `tool_search_call` (which tool the model looked for), `tool_search_result` (the loaded schema) and `function_call` (the call to run). Your application only executes the last step; the first two are resolved inside the API. Google notes this also helps debugging, since the tools the model considered are visible in the record. For tools with long descriptions, a `short_description` field can be added so the model sees a compact summary during retrieval.

## Server side or client side

The default is server-side retrieval. Gemini runs the search on its own servers, so there is no index to build or host and no extra round trip. The guide recommends it for large, known tool libraries and MCP servers, and for latency-sensitive apps, since the search finishes inside one API call.

If you maintain your own tool registry, embedding index or per-user permission filter, client-side retrieval comes in. You give the `tool_search` tool `"execution": "client"` and define your search parameters. When the model calls it, your application runs the lookup and returns matching function declarations. Each search adds a round trip, but tools do not need to be declared up front, so a new connector can be offered as soon as a user adds it mid-conversation. According to the guide's summary table, static loading suits fewer than 20 stable tools, server-side retrieval suits large libraries, and client-side retrieval suits dynamic or per-user tools.

Remote MCP servers get even simpler. Setting `defer_loading: true` on an `mcp_server` entry defers every tool that server exposes, so a large server can be connected without listing its tools one by one.

## Things to watch

The guide spells out a few rules. Only one `tool_search` entry is allowed per request. The API does not keep tool declarations between turns, so the full tools array must be sent on every request. Apps that manage conversation history themselves must keep the search steps in order and pass back the encrypted `signature` field on each step unchanged, or the API returns a 400 error. Because the feature is in preview it requires the v1beta version, and Google says the API surface may change before general availability. The older `generateContent` method does not support it.

## Pricing and caching

There is no separate charge for Tool Retrieval; tokens are billed at the standard rate of the model you call. Google says turning on `tool_search` adds a small, fixed block of input tokens, and each schema the model loads counts as input for the rest of the conversation. You save when the schemas you never load outweigh those you do, which Google calls the usual case for large libraries while advising developers to measure against their own traffic. The feature also works with prefix caching: deferred schemas stay out of the start of the prompt and loaded ones are added later, so the cached prefix stays the same from turn to turn.

## Which models it works with

According to Google's [changelog](https://ai.google.dev/gemini-api/docs/changelog?ref=globalfeed.ai), Tool Retrieval works with Gemini 3.6 and later models, including all Gemini 4 models, in the Interactions API. The guide's samples are written in Python, JavaScript and REST and use the gemini-4-hydrogen model. A developer who wants to try it can start by adding a `tool_search` to an existing tools array and deferring the long tail, then check the search steps in the response to see whether the model finds the right tool.

Sources: [Google announcement](https://blog.google/innovation-and-ai/technology/developers-tools/gemini-api-tool-retrieval/?ref=globalfeed.ai), [Gemini API Tool Retrieval guide](https://ai.google.dev/gemini-api/docs/tool-retrieval?ref=globalfeed.ai), [Gemini API changelog](https://ai.google.dev/gemini-api/docs/changelog?ref=globalfeed.ai)