Gemini Tool Retrieval: Secure Multi-Tool AI Agents
Gemini Tool Retrieval, previewed November 19, loads schemas on demand. Names still reach the model. Build a multi-tool agent that stays scoped.
By Muhammad Saif and Aashan Khan · Techtribe co-founders
Gemini Tool Retrieval is a way to keep a large tool library attached to an agent without sending every parameter schema on every request. Google announced the preview on November 19, 2026 in the Interactions API. The launch post, Gemini API tool retrieval for efficient agent scaling, describes the failure mode it is aimed at: dozens or hundreds of tools inflate input tokens, add latency, and make the model worse at picking the right tool. Retrieval keeps the library on standby and loads a full schema when the current task needs it.
That is a product feature for people building agents. It is also a security boundary only if you add one. The model still sees the name of every deferred tool and a short description. A description is text. Text is how a poisoned tool steers an agent. The work of deciding which tool a given user may call does not move into the retrieval flag. It stays in your code, on the call, with a credential that cannot do the next-worse thing.
This note is how to use the feature without pretending the token savings are a permission system. If the tools themselves are MCP servers, read whether those servers are safe to connect before you defer them. Deferral does not review a server. It delays the schema.
What the preview actually changes
To turn retrieval on, the launch post says you add a tool_search tool and set defer_loading: true on the tools you want held back. The model still sees the name and description of each deferred tool, so it knows what exists, and the parameter schema stays out of the initial context. When the model needs a tool, it asks for it by name, the API loads the schema, and the model calls the function, inside the same request when retrieval runs on the server.
Google's tool retrieval guide marks the feature as preview on the v1beta API, and says the surface may change before general availability. It also says generateContent does not support retrieval. If your integration still calls the older method, this feature is not available there. Plan on the Interactions API, and plan on a migration if you prototype against a preview and the fields move.
The guide splits the work into three modes.
Static loading sends every schema on every request. Google recommends it when you have fewer than about twenty stable tools and the search overhead is unnecessary. There is no extra retrieval code. Remote MCP servers can be declared this way too.
Server-side retrieval is the default tool_search. Gemini loads deferred schemas on demand. You write no ranking code. The search, the schema load, and the function call happen in one API request, which is why Google points latency-sensitive apps at this mode. Remote MCP servers support defer_loading, so a large server does not have to be pasted into the prompt tool by tool.
Client-side retrieval sets execution to client and moves the search into your application. You declare the search tool's name, description, and parameters. When the model calls it, you run your own lookup and return matching function declarations in the function result. Google's guide says this mode is the one for dynamic registries, namespaces, and per-user tools. It costs an extra round trip per search. It is also the mode where you can refuse to return a tool the current user must not see.
The launch post says retrieval has no separate charge. Tokens are billed at the model's normal rates. Turning on tool_search adds a small fixed block of input tokens, and each schema the model loads is billed as input for the rest of the conversation, the same as a tool you had declared up front. You save tokens when the schemas you never load outweigh the ones you do. The guide adds a sharper version: deferred tools contribute a name and a short description, or the first sentence of the description, until they are loaded. Each server-side search triggers an extra model call inside the request, reported with tool-use tokens and billed as input. Measure this on your traffic. A small library, or a long context that searches on every turn, can cost more than static loading.
Prefix caching is part of the design. Deferred schemas stay out of the front of the prompt, and loaded schemas are appended later, so the cached prefix can stay stable across turns. The guide notes the opposite risk too: deferring tools shrinks the prompt, and a prompt that falls below the model's minimum cacheable size stops benefiting from implicit caching. A cost win on schema tokens can be a cost loss on cache hits. Read both numbers.
Supported models, on the guide at the time of writing, include Gemini 4 variants and Gemini 3.6 and 3.8 flash models. The launch post summarizes that as Gemini 3.6 and later, including Gemini 4, in the Interactions API. Preview lists change. Pin the model id you tested, and re-read the changelog before you promise a customer a specific name.
A shorter prompt is not an access-control list
Tool retrieval solves a context problem. Authorization is a different problem, and it fails in the same places it failed when every schema was inline.
The model is told the tool exists. A deferred billing tool still has a name and a sentence of description in the first request. Anyone who can influence that description can influence the model: a tool called export_invoice whose description says to include the full customer record will be used that way when the task is "help with this invoice." Holding the JSON schema back does not hold the sentence back. Review descriptions the way you review code. A one-line description is easier to review than a full schema, which is a real advantage, and it is still untrusted text if it comes from outside your repo.
Loaded schemas join the conversation. From that turn forward they are in context, billed as input, and visible to the model for later turns. A tool you hoped would stay dormant is fully present once the model has asked for it. Session-long agents accumulate schemas. A support agent that has, over twenty turns, loaded refunds, identity lookup, and a production database tool is back to a wide tool set, just later in the transcript. Reset the tool set when the task changes. Do not carry a resolved incident's tools into the next customer's chat.
Server-side retrieval loads whatever the model names, from the library you declared. If you declared an admin tool next to a read-only tool, the model can ask for the admin tool. Google will load the schema. Your server still has to refuse the call when the user is not an admin. The refusal belongs in the function implementation, checked against the session, on every invocation. A prompt line that says "only managers may refund" is advice. The API key on the refund tool is the capability.
Client-side retrieval is where the library itself can be filtered. The model asks your search tool for something, and you return only the declarations this user may call. That is the right mode when tools differ by tenant, by role, or by which integrations the customer connected. It is extra code, and it is the code that earns its keep. Do not return a tool "just in case" because the description seemed relevant. Relevance is the model's job. Permission is yours. If your search is a vector index of every internal API, you have rebuilt the wide library inside the index. Filter by an allow list for the tenant first, then rank.
Remote MCP servers with defer_loading are convenient and they are someone else's process. The Gemini API can hide their schemas until needed. It cannot make a malicious or over-scoped server safe. A server that holds a production token still holds it when the schema is deferred. Read the server's tools before you set the flag, pin the version, and give it a credential that cannot touch production. The confused-deputy problem does not care that you saved input tokens.
Function results are a second channel. The model sees whatever your tool returns. A search tool that returns a schema is supposed to. A data tool that returns a full customer export because the description was vague is a leak you caused after retrieval worked correctly. Scope the query inside the function. Return the fields the task needs. Log the call with the user id and the tool name, with secrets redacted.
How to structure the library
Keep three to five tools loaded if they are on almost every turn. Google's own learning guide suggests that split: frequent tools stay inline, the long tail is deferred. A support agent might always have "identify the account" and "search the last ten tickets," and defer refunds, plan changes, and exports. The model stays accurate on the common path, and the rare path pays for a schema only when it is used.
Name tools for a human reviewer. billing_get_customer is reviewable. tool_17 is how a poisoned or mistaken description becomes the only documentation. Put the name, the one-line description, the side effect (read or write), and the scope (which account, which environment) in a registry you own, in the same repository as the agent. Generate the API declaration from that registry so the text the model sees cannot drift from the text you reviewed.
Split read and write. A single tool that "manages the subscription" will be used to cancel when the user asked to explain. Two tools, one of which your server rejects unless a person confirmed, match the way you already think about production changes. Retrieval does not add the confirmation. Your handler does, outside the model, with a record of who confirmed.
Split environments. A tool whose implementation points at production data should not be in the library of an agent running on a developer's laptop against staging credentials. The model will call the tool that looks relevant. If both are present, you are one description away from a production read. Separate registries per environment are a small amount of structure. A shared registry with a comment that says "careful" is how the production tool gets deferred and then loaded.
Timeouts, argument checks, and rate limits sit in the handler. The Interactions API can load a schema that says an id is a string. Your service still rejects an id that is not this tenant's id. Retrieval will not do that for you. The schema is a hint to the model. The check is yours.
Observability comes with the feature because the bill is now split between a stable prefix, search tokens, and loaded schemas. Log which tools were loaded per session, how often search runs, and which calls wrote data. A tool that is loaded on every turn and was supposed to be rare is either mis-described or being steered. Both are reasons to look. Cost monitoring for agents that loop is the sibling problem in what an agent spends when nobody stops it. Retrieval reduces one kind of waste and does not cap a runaway tool loop. Put a turn limit on the agent anyway.
What to check before a multi-tool agent faces a customer
- List every tool the agent can cause to load, including every tool a deferred MCP server exposes. If you cannot name the server's tools, do not defer it. Deferral is not an inventory.
- Mark each tool read or write, and name the credential it uses. A write tool uses a credential that cannot be the admin role. A read tool for tenant A cannot query tenant B, tested with two real tokens, not with a code comment.
- Read every short description that will be visible while the schema is deferred. Reject descriptions that mention other tools' credentials, tell the model to ignore rules, or claim a side effect the handler does not enforce.
- Decide the mode on purpose. Under twenty stable tools, static loading is what Google recommends and it is easier to review. A large shared library can use server-side retrieval. Anything that depends on the user uses client-side retrieval with a filter in front of the ranker.
- Confirm the model id and the API method. Preview behavior on
v1betais allowed to change. Pin them in config. A silent move back togenerateContentwill drop retrieval and may send every schema again, or fail the call. Know which. - Measure a week of real conversations: tokens before and after, how many schemas load per session, and whether the cached prefix survived. Ship the configuration that is cheaper on your traffic. The launch post is explicit that you should measure, because the savings depend on how many tools a turn actually uses.
- Log the tool name, the user, and the outcome. Keep the argument log free of secrets. If you cannot tell which tool fired after a customer reports a wrong refund, you are not ready to add the next twenty tools.
Re-check the list when someone adds a tool in a pull request. The registry diff is the review. An agent that can edit its own tool registry and also call the tools is a loop you do not want. Protect that directory the way you protect CI workflows.
What does not hold
A system prompt that lists the tools the model "should" use does not hold once retrieval can load anything you registered. The model will follow the task in front of it. Unused tools have to be absent from that user's registry, or the handler has to reject them. Preference is not enforcement.
Hiding a parameter from the initial prompt does not hold as data protection. The moment the tool is used, the schema and the result are in the conversation, and the conversation is sent to the model provider under whatever retention that call has. Tool retrieval does not change your data-processing terms. If the tool result contains customer data, that data left your network when the model read the result. The provider question is covered in what happens when a model provider leaks prompts.
Trusting a remote MCP server because its schema is deferred does not hold. You deferred metadata. The server still runs with the token you gave it. A rug pull on the tool definition, where the server changes behavior after you approved it, is still a reason to pin and re-read definitions. Retrieval will cheerfully load the new schema.
Putting every internal API into client-side search "so the model can find it" does not hold. Search quality goes up when the index is relevant and goes down, from a security point of view, when the index is complete. Return the intersection of "relevant" and "allowed." If your filter fails open when the index errors, fix the failure direction before you launch. A search outage should return no tools, not all tools.
Skipping static loading for a five-tool agent does not hold as modernization. You will spend preview risk and search tokens to avoid a prompt that already fit. Google's own split exists so you do not do that. Use the small path while the product is small. Add retrieval when the library, measured in tokens and in wrong tool choices, is actually large.
A build sequence that stays reviewable
Start with the user task, not with the tool catalog. Write down the three outcomes the agent must complete without a person, and the outcomes that must wait for a person. Tools map to those outcomes. A catalog of eighty endpoints copied from an internal developer portal is how agents get broad and expensive in the first week.
Implement the handlers with the checks, against staging, with static tool declarations if the count is low. Add traces before you add retrieval. You want a baseline of tokens, latency, and wrong-tool rate. Then turn on server-side retrieval for the long tail and compare a week of the same traffic. Keep the change if the tool-choice errors fell and the bill fell. Revert if only the architecture diagram improved.
Introduce client-side filtering when a second tenant exists, not before. Multi-tenant tool registries built for a single-tenant prototype tend to return everyone's tools and "filter later." Later is the incident. The second tenant is the forcing function. If you already have many tenants, do the filter before the agent is allowed to call a write tool in production.
Put a person on the first month of write-tool transcripts. Retrieval will load surprising tools for surprising phrasings. The surprise is useful while the volume is low. A refund tool loaded for "what is my balance" is a description bug or a routing bug. Fix it while the log fits on one screen.
Document the mode in the runbook: which model, which API, which tools are deferred, who may add a tool. Preview features need an owner. When Google changes the field names, that owner updates the integration. An unowned preview in a customer-facing agent is how a Tuesday changelog becomes a Friday outage.
If the agent is the product, the packaging matters as much as the flag. Customers will ask which model sees their data, whether tool results are retained, and how you turn a tool off for their workspace. Answer those in the product, with a setting you can demonstrate. A PDF that says "we take security seriously" is not a substitute for a per-tenant tool allow list you can show on a call.
If this is your app, send the repo.
A 30-minute scope call. We read what is live, name what is dangerous, and quote a fixed scope.
How Techtribe builds the agent and the tool boundary
We design the tool registry around the tasks the product actually performs, wire Gemini retrieval only where the library is large enough to pay for it, and put the permission check in the handler so a loaded schema cannot reach another tenant's data. You get the agent in your repo, the traces for cost and for tool choice, and a written list of which tools can write.
That build is a Production MVP when the agent is a product customers will depend on: brand, auth, a small set of integrations, evals, and monitoring are the work, not a demo that calls twenty APIs from a laptop. If you already have the product and you need the tool layer brought under control while feature work continues, a Dedicated Team can own the registry and the reviews. The longer service page for this kind of build is AI agent development.
Bring the list of systems the agent must touch, a week of real requests if you have them, and the rule for what a tool must never do without a person. If you do not have that rule yet, the scope call is where we write the first version with you. We would rather ship five tools that check the tenant than fifty that share one admin key.
The fixed scope for taking a generated app to production is a page per tool: Lovable, Bolt, v0, and Replit.
Questions
What is Gemini Tool Retrieval?
Google announced it on November 19, 2026 as a preview in the Gemini Interactions API. You add a tool_search tool and set defer_loading on functions or remote MCP servers. The model sees names and short descriptions first, then loads a full parameter schema when the task needs that tool.
Does deferring a schema keep the tool's data private?
No. Deferral changes when the parameter schema enters the prompt, which cuts tokens on large libraries. The model still learns that the tool exists. Authorization has to live in your service, on every call, with a token scoped to the user. A shorter prompt is not an access-control list.
Which models and APIs support it?
Google's docs say Tool Retrieval is preview, on the Interactions API, and requires the v1beta surface. generateContent does not support it. Google's launch post says it works with Gemini 3.6 and later, including Gemini 4 models. Confirm the model id on the current docs before you depend on a name from a blog.
When is static tool loading still the right choice?
Google's guide says static loading fits fewer than about twenty stable tools, where search overhead is unnecessary. Server-side retrieval fits large known libraries and remote MCP servers. Client-side retrieval fits registries that change per user, where your code must filter before a schema is returned.