Back to Articles

Managing AI Agents: A Breakthrough with Gemini Tool Retrieval

November 22, 2026773

A Breakthrough in AI Agent Management: How to Manage Hundreds of Tools Without Suffocating the Model

One of the most significant challenges in building complex AI agents is managing their tools. As an agent becomes more "all-knowing," the library of tools we need to provide grows. The problem? Sending all parameter definitions for dozens or hundreds of tools in every prompt is a recipe for inflated costs, increased latency, and a drop in the model's accuracy when choosing the right tool.

Google has introduced a significant solution in the Gemini API that changes the rules of the game: Tool Retrieval. Instead of overloading the model with all information upfront, the model learns only what it needs, exactly at the moment it needs it.

How It Works in Practice

The idea behind Tool Retrieval is simple yet powerful. Instead of sending the full schema of every tool, we define our tools with a new flag called

defer_loading: true
.

When we enable this capability (by adding

tool_search
to the request), the model receives only the name and a short description of the tool. It knows the tool exists, but it doesn't "see" its complex parameters until the moment it decides to use it. At the moment of decision, the API loads the full schema, and the model executes the function call – all within that single request [1, 8].

Key Advantages:

  • •Token Savings: Since most tools are not loaded in the full context, we save tens of thousands of tokens per call [3, 5].
  • •Improved Accuracy: With less "noise" from unnecessary definitions in the prompt, the model tends to choose the correct tool with much higher precision [1, 9].
  • •Caching Maintenance: Because the loaded tool definitions enter the continuation of the conversation rather than the start of the prompt, the conversation prefix remains stable and can be cached for reuse [7, 9].

Two Approaches to Tool Management

The Gemini API offers two main ways to implement this capability [3, 5]:

  1. •Server-side Retrieval (Default): Google manages the search for you. You simply mark which tools to defer, and the model knows how to search and retrieve them itself. This is the fastest and simplest solution for most cases [2, 7].
  2. •Client-side Retrieval: Here, control shifts to you. Your application performs the search and returns the relevant tools to the model. This is especially suitable for cases where you have a dynamic tool registry, complex user permissions, or tools that change on the fly [2, 3].

Summary and Conclusions

The ability to use Tool Retrieval is a quantum leap for agent developers. If until today you had to limit your agent's number of tools to 10-20 to maintain performance [10], you can now expand your agents' capabilities to hundreds of tools without sacrificing speed or budget.

Practical Tip: Don't defer all tools. Keep the tools you use frequently available immediately, and move the "long tail" of less common tools to

defer_loading
. This is the perfect balance between performance and user experience.

For more information and to get started, it is recommended to review the official Gemini API Tool Retrieval documentation.

Written by Daniel Rechtman - Expert in Cloud, AI, and No-Code Development. Telegram | WhatsApp | Instagram

Thanks to Spotlight by Daniel Trabelsi by Daniel Trabelsi for sharing and inspiring this article.

Join the channel
#AI agents#Gemini#artificial intelligence#tool retrieval#Gemini API#AI development#token optimization