Gemini Tool Retrieval Explained: Fewer Tokens for AI Agents

Dileep Solanki

By Dileep Solanki · Published and last updated: 21 November 2026 · The feature is in preview, so details may change.

Every tool you give an AI agent has a hidden cost. Before the agent does anything, the full description of each tool, including every parameter, is sent to the model, and sent again on every request. With three tools that hardly matters. With a hundred, it becomes a real bill and a real accuracy problem. On 19 November 2026, Google announced Tool Retrieval for the Gemini API, which tries to fix this. This guide explains how it works, shows a small experiment I ran to measure the potential savings, and lists the ways it can go wrong.

The problem: tools cost tokens on every request

Google's announcement describes it plainly. When an agent connects to dozens or even hundreds of tools, sending every full parameter schema on every request inflates input token counts, adds latency, and lowers tool-selection accuracy as the candidate list grows.

A "schema" is the structured description of a tool: its name, what it does, and the list of inputs it accepts, each with a type and explanation. It's what lets the model call the tool correctly. It is also long.

What Tool Retrieval does

Instead of loading every schema up front, the agent keeps most tools on standby. Per Google, to turn it on you add a tool_search tool to the request and set defer_loading: true on the tools you want to hold back. The mechanics:

  1. The model still sees the name and description of every deferred tool, so it knows what exists.
  2. The parameter schemas stay out of context.
  3. When the model needs a tool, it asks for it by name, the API loads that schema, and the model calls the function, all within the same request.

A few more details from the announcement:

  • There is no index to build or host, because Gemini runs the search on the server.
  • You can keep your most-used tools loaded up front and defer the long tail.
  • It also works with remote MCP servers. Setting defer_loading: true on an mcp_server tool loads every tool that server exposes on demand. MCP, the Model Context Protocol, is the open standard many agents use to connect to external tools.
  • The steps are visible for debugging: all three steps appear in interaction.steps, so you can inspect which tools the model considered.

For teams with their own system, there is a client-side mode. If you maintain your own tool registry, embedding index or per-user permission filter, you declare the tool_search with "execution": "client", and the approach adds one round trip per search because your app runs the lookup.

Here is the shape of a request, adapted from Google's example. I didn't run this against the API, because I don't have a key:

tools = [
    {"type": "tool_search"},
    {
        "type": "function",
        "name": "issue_refund",
        "description": "Refund an order to the original payment method.",
        "defer_loading": True,          # schema stays out of context until needed
        "parameters": {
            "type": "object",
            "properties": {"order_id": {"type": "string"}, "amount": {"type": "number"}},
            "required": ["order_id", "amount"],
        },
    },
    # ... many more deferred tools
]

Pricing, availability and fine print

  • Cost: Tool Retrieval has no separate charge. Input and output tokens are billed at the model's standard rates. The feature adds a small fixed block of input tokens, and each schema the model loads is billed as input for the rest of the conversation, just like a tool declared up front. You come out ahead only when the schemas you never load outweigh the ones you do. Google's own advice is to measure against your own traffic.
  • Status: it's in preview and, according to reporting on the documentation, requires the v1beta API version, and the docs warn that the API surface may change before general availability.
  • Interface: it works only in the Interactions API, not the older generateContent method. Unite.AI notes the Interactions API became generally available in June 2026 and is Google's recommended interface for new projects.
  • Models: Google's blog says it works with Gemini 3.6 and later models, including all Gemini 4 models. One report on the documentation lists a narrower set, Gemini 4 Hydrogen, Gemini 4 Argon, Gemini 3.8 Flash and Gemini 3.6 Flash, and says setting the flag on any other model returns an error. Check the current docs before you build.
  • A limitation to know: Unite.AI reports that retrieved schemas cannot be unloaded and the complete tools array must be resent on every request. That fits Google's note that loaded schemas keep costing tokens for the rest of the conversation.

An experiment: how much could you skip?

I wanted to put numbers on the idea without needing an API key. So I built 40 realistic but made-up tools (email, calendar, orders, payments, files, GitHub and so on), each with a name, a one-line description and 1 to 4 parameters. Then I measured three setups by size in characters, which is only a rough stand-in for tokens:

  • A: every full schema in every request.
  • B: only names and descriptions in the listing, plus the one schema actually used.
  • C: a client-side approach where my own keyword search (TF-IDF, from our RAG tutorial) picks the top three tools, and only their schemas are sent.

I also wrote 14 requests, each with a known correct tool, and checked whether keyword retrieval finds it. I wrote the test requests before running anything and did not tune the code after seeing the results.

The core of the script (the full file, with all 40 tool definitions, is [add your Gist link here]):

def schema(tool):
    name, desc, params = tool
    return {"name": name, "description": desc,
            "parameters": {"type": "object",
                           "properties": {p: {"type": t, "description": d} for p, t, d in params},
                           "required": [p for p, _, _ in params[:2]]}}

def size(obj):
    return len(json.dumps(obj, separators=(",", ":")))

# Retriever over name + description (what a deferred listing would expose)
docs = [n.replace("_", " ") + ". " + d for n, d, _ in TOOLS]
vec = TfidfVectorizer(stop_words="english", sublinear_tf=True)
matrix = vec.fit_transform(docs)

def retrieve(query, k=3):
    scores = cosine_similarity(vec.transform([query]), matrix).ravel()
    order = scores.argsort()[::-1][:k]
    return [(NAMES[i], float(scores[i])) for i in order]

I ran it on Python 3.12.3 with scikit-learn 1.9.1. This is the real output:

40 tools
A) Every full schema in every request :  12947 characters
B) Names + descriptions only          :   3421 characters (26% of A)
B') Listing + the one schema actually used (avg over 14 requests): 3763 characters (29% of A)
C) Client-side top-3 retrieved schemas only (avg)                 : 987 characters (8% of A)

Keyword retrieval: hit@1 = 11/14, hit@3 = 12/14
  MISS  q='The package arrived damaged, give the customer 40 dollars back'
        expected=issue_refund  got=[('lookup_customer', 0.47), ('update_customer_email', 0.46), ('merge_customer_accounts', 0.44)]
  MISS  q='Is it going to rain in Jaipur this weekend?'
        expected=get_weather  got=[('create_chart', 0.0), ('run_sql_query', 0.0), ('get_leave_balance', 0.0)]
  MISS  q='Show me errors from the checkout service in the last hour'
        expected=get_error_logs  got=[('deploy_service', 0.61), ('get_error_logs', 0.31), ('get_leave_balance', 0.0)]

What the results show

Setup Characters per request Share of full
A. All full schemas 12,947 100%
B. Listing only 3,421 26%
B′. Listing plus the one schema used (average) 3,763 29%
C. Top-3 keyword-retrieved schemas (average) 987 8%
  1. Deferring cuts the size a lot. Showing only names and descriptions was about a quarter of the full size in this setup. Deferred loading looks worthwhile for large libraries, matching Google's reasoning.
  2. The cheapest option is also the riskiest. Sending only the top three keyword results was the smallest at 8%, but it missed the right tool first in 3 of 14 requests, and in one case missed it entirely. Missing the tool means the agent can't act.
  3. Keyword search fails in the familiar ways. "Give the customer 40 dollars back" doesn't contain the word "refund". "Is it going to rain" shares no words with "weather forecast". That second query scored exactly 0.0 against every tool, so the top three were arbitrary. This is the same vocabulary-mismatch problem we saw in the RAG tutorial, and the same lesson applies: check the score, and don't trust a zero.
  4. The listing keeps the model in the loop. One reasonable reading, and this is my inference, not a tested result, is that Google's server-side design lets the model itself read the full list of names and descriptions, so it isn't limited by keyword overlap the way my baseline is. I didn't test Google's retriever, so I can't say how often it picks correctly.

Limits of my experiment

  • Characters are not tokens. Real tokenizers count differently, so treat the percentages as rough proportions.
  • The tools are synthetic and short. Real-world tool schemas, especially from MCP servers, can be much longer or shorter than mine.
  • Fourteen requests is a tiny test. The 11/14 figure shows the behaviour, not a benchmark.
  • My "B′" figure ignores the fixed tool_search overhead and the fact that loaded schemas keep costing tokens in later turns, so over a long conversation the real saving is smaller than shown.
  • I didn't call Google's API, so nothing here measures its actual accuracy, latency or billing.

Where it can go wrong

  1. Descriptions now do the selecting. When schemas are hidden, the model chooses tools from names and one-line descriptions alone. Vague descriptions such as "handles orders" will cause wrong or missed tool calls. Write them as if they were the only thing the model would ever read.
  2. Retrieval misses. If you use client-side retrieval, test it with an evaluation set, as above, before you trust it.
  3. Extra round trips. Client-side mode adds one per search, which adds latency.
  4. Preview instability. The API may change before general availability.
  5. Security still applies. Hiding a schema doesn't grant or restrict permission. Keep per-user access checks in your own code. Treat tool descriptions from third-party MCP servers as untrusted text, since a malicious description can try to steer the model. That is general agent-security guidance, not something specific to Google's announcement.

The same week, LangChain put its LangSmith Tool Gateway into public beta. According to one news roundup, it centralizes credentials, caller identity, access policies, approval flows and audit traces for every agent tool call, and works with MCP-compatible clients. It tackles a related problem, governing which tools agents may use, and shows that the industry is converging on tool management as a major agent challenge.

Should you use it?

  • Fewer than about ten tools: probably not worth the complexity.
  • Dozens of tools or large MCP servers: worth a trial, because the savings potential is largest.

If you try it, a sensible sequence:

  1. Record your current input-token usage on real traffic.
  2. Keep your five to ten most frequently used tools undeferred.
  3. Defer the long tail, and rewrite weak descriptions first.
  4. Inspect interaction.steps for wrong or missing searches.
  5. Compare tokens, latency and correct-tool rate with your baseline before adopting it.

Final assessment

Tool Retrieval attacks a genuine scaling problem, and my small experiment supports the basic logic: a listing is far smaller than a full set of schemas. But the savings come with new risks, and the winners will be teams that write clear tool descriptions and measure their results. Treat it as a preview feature to test, not a switch to flip across production.

How this article was made

This article was researched and drafted with AI assistance and edited against the sources below. I read Google's announcement directly. The experiment was run on Python 3.12.3 with scikit-learn 1.9.1, and the output shown is the real output. I did not call the Gemini API or test the feature itself, and the example request is adapted from Google's post and untested. Preview features change quickly, so check the current documentation. This is educational content, not production advice, and it contains no sponsored placements or affiliate links.

Sources and Further Reading

3/related/default