Google 在 Gemini API 的 Interactions API 中以预览形式推出 Tool Retrieval,开发者可通过添加 tool_search 工具并设置 defer_loading: true,让模型按需加载工具参数 schema,而非在每次请求中发送完整工具库。该功能旨在降低输入 token 与延迟,并在工具库规模扩大时保持工具选择准确率,支持 Gemini 3.6 及之后模型(含全部 Gemini 4 模型)。
Google launched Tool Retrieval in preview in the Gemini API's Interactions API. By adding a tool_search tool and setting defer_loading: true, developers let models load tool parameter schemas on demand instead of sending the full tool library with every request. The feature aims to cut input tokens and latency while keeping tool selection accurate as tool libraries scale, and works with Gemini 3.6 and later models, including all Gemini 4 models.
Tool Retrieval 现已在 Gemini Interactions API 中提供预览版。按需加载工具参数 schema,而无需在每次提示中发送完整的工具库,旨在减少输入 token,并在你的 agent 扩展时保持工具选择的准确性。
Tool Retrieval is now in preview in the Gemini Interactions API. Load tool parameter schemas on demand instead of sending your full tool library in every prompt,designed to reduce input tokens and keep tool selection accurate as your agent scales.
你的浏览器不支持音频元素。
Your browser does not support the audio element.
我们在 Gemini API 中推出 Tool Retrieval,帮助你的 agent 更高效地管理大型工具库。通过仅在需要时加载参数 schema,你可以降低复杂任务的延迟和输入 token 成本。你今天就可以在 Interactions API 中试用此功能,只需添加一个 tool_search 工具,并在请求中将 defer_loading 设置为 true。
We are launching Tool Retrieval in the Gemini API to help your agents manage large tool libraries more efficiently. By loading parameter schemas only when needed, you reduce latency and input token costs for complex tasks. You can try this feature today in the Interactions API by adding a tool_search tool and setting defer_loading to true in your requests.
我们推出 Tool Retrieval,帮助开发者更高效地管理大量软件工具。你的 agent 不再一次性加载所有工具,而是将工具库保持在待命状态,仅在任务需要时拉取具体的详细信息。这减少了数据用量、加快了性能并提高了准确性。你今天就可以使用我们最新的 Gemini 模型开始使用此功能,构建能力更强、响应更快的应用。
We are introducing Tool Retrieval to help developers manage large collections of software tools more efficiently. Instead of loading every tool at once, your agent now keeps a library on standby and only pulls in the specific details it needs for a task. This reduces data usage, speeds up performance, and improves accuracy. You can start using this feature today with our latest Gemini models to build more capable and responsive applications.
今天我们将在 Gemini API 中推出 Tool Retrieval,现已在 Interactions API 中提供预览版。
Today we're launching Tool Retrieval in the Gemini API, available in preview in the Interactions API .
当一个 agent 连接数十甚至数百个工具时,每次请求都发送每个完整的参数 schema 会迅速累积开销。这会增加输入 token 数量、增加延迟,并且随着候选列表增长而降低工具选择的准确性。Tool Retrieval 让你的 agent 将完整的工具库保持在待命状态,仅在当前任务需要时加载参数 schema。
When an agent connects to dozens or even hundreds of tools, sending every full parameter schema on every request adds up fast. It inflates input token counts, adds latency, and lowers tool-selection accuracy as the candidate list grows. Tool Retrieval lets your agent keep its full tool library on standby and load parameter schemas only when the current task needs them.
要开启 Tool Retrieval,请在请求中添加一个 tool_search 工具,并为你想要暂缓加载的工具设置 defer_loading: true。模型仍然能看到每个延迟加载工具的名称和描述,因此它知道有哪些工具可用,但参数 schema 不会进入上下文。当模型需要某个工具时,它会按名称请求该工具,API 会加载完整的 schema,然后模型调用该函数,这一切都在同一个请求内完成。
To turn on Tool Retrieval, add a tool_search tool to your request and set defer_loading: true on the tools you want to hold back. The model still sees the name and description of every deferred tool, so it knows what's available, but 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, all inside the same request.
在这单次 API 调用中,模型会搜索 issue_refund,API 加载其 schema,随后模型发出 function_call。这三个步骤都会出现在 interaction.steps 中,因此在调试工具名称或描述时,可以轻松查看模型考虑过哪些工具:
Inside that single API call, the model searches for issue_refund , the API loads its schema, and the model emits the function_call . All three steps appear in interaction.steps , making it easy to inspect which tools the model considered when debugging tool names or descriptions:
从这里开始就是常规的函数调用:你的代码执行退款并返回一个 function_result。
From here it's normal function calling: your code runs the refund and sends back a function_result .
无需构建或托管索引。Gemini 在服务器端运行搜索,因此你的代码只需改动两处:新增该工具,以及在你想要延迟加载的工具上设置一个标志。你可以将最常用的工具预先加载,而将长尾工具延迟加载。
There's no index to build or host. Gemini runs the search on the server, so the only changes to your code are the new tool and a flag on the tools you want to defer. You can keep your most-used tools loaded up front and defer the long tail.
Tool Retrieval 也能与前缀缓存良好配合。延迟加载的 schema 不会出现在提示词开头,模型加载的 schema 会在对话稍后加入,因此缓存的前缀在各轮之间保持不变。
Tool Retrieval also plays well with prefix caching. Deferred schemas stay out of the start of the prompt, and the schemas the model loads are added later in the conversation, so the cached prefix stays the same from turn to turn.
Tool Retrieval 也适用于 Gemini API 中的远程 MCP 服务器。在 mcp_server 工具上设置 defer_loading: true,该服务器暴露的每个工具都会按需加载,因此你可以连接一个大型服务器,而无需逐一列出其工具。
Tool Retrieval also works with remote MCP servers in the Gemini API . Set defer_loading: true on an mcp_server tool and every tool that server exposes is loaded on demand, so you can connect a large server without listing its tools one by one.
如果你维护自己的工具注册表、嵌入索引或按用户权限过滤器,请将 tool_search 声明为 "execution": "client" 并定义你的搜索参数。客户端检索每次搜索会增加一次往返,因为查找由你的应用执行。工具无需预先声明,因此当用户连接某个集成时,你也可以在对话中途暴露新工具:
If you maintain your own tool registry, embedding index, or per-user permission filter, declare the tool_search with "execution": "client" and define your search parameters. Client-side retrieval adds one round trip per search, because your app runs the lookup. Tools do not need to be declared upfront, so you can also expose new tools mid-conversation when a user connects an integration:
Tool Retrieval 不单独收费。输入和输出 token 按你所调用模型的标准费率计费。开启 tool_search 会增加一小段固定的输入 token,模型加载的每个 schema 都会在对话剩余部分作为输入计费,与预先声明的工具相同。当从未加载的 schema 多于已加载的 schema 时,你就能节省 token,这在大型工具库中通常是常见情况。请根据你自己的流量进行衡量。
Tool Retrieval has no separate charge. Input and output tokens are billed at the standard rates for the model you call. 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 declared up front. You save tokens when the schemas you never load outweigh the ones you do, which is the usual case for large libraries. Measure it against your own traffic.
Tool Retrieval 在 Interactions API 中适用于 Gemini 3.6 及更高版本模型,包括所有 Gemini 4 模型。
Tool Retrieval works with Gemini 3.6 and later models, including all Gemini 4 models , in the Interactions API.