Press "Enter" to skip to content

Gemini智能体改为按需加载工具,开发者可节省令牌用量

谷歌于11月19日在Gemini Interactions API中推出Tool Retrieval预览功能。智能体可以把庞大的工具库放在待命状态,只在任务真正需要某个工具时,才加载该工具的完整参数结构。发布文章由Gemini API产品经理Lucia Loher和谷歌DeepMind研究科学家Nora Kassner共同署名。

文章把问题说得很直接。当一个智能体连接几十甚至几百个工具时,每次请求都发送全部完整结构,会推高输入令牌数量、增加延迟,工具清单越长,模型选错工具的概率也越高。新功能开启方式只需两处改动。开发者在请求中加入tool_search工具,并把每个待延后工具的defer_loading设为true。模型仍能看到每个工具的名称和说明,知道有哪些工具可用,参数结构则留在提示之外,直到模型按名称请求某个工具,API才加载结构,模型在同一次请求内完成函数调用。

谷歌在文中完整走了一个例子。一位客户说订单A-1042到货时已损坏,要求退还40美元。在这一次调用中,模型搜索名为issue_refund的函数,API返回其结构,模型随即发出带有订单号和金额的函数调用。三个步骤都记录在interaction.steps中,开发者在调用出错时可以检查模型考虑过哪些工具。本站本周还刊登了西班牙国王费利佩六世在毕尔巴鄂颁奖等报道。

文中还有两个细节对拥有大型工具库的团队比较重要。延后加载的结构不出现在提示开头,因此团队使用前缀缓存时,每一轮的缓存前缀保持不变。Tool Retrieval也支持远程MCP服务器。把mcp_server工具的defer_loading设为true,服务器对外提供的全部工具都会按需加载,团队不必逐个列出工具就能接入一台大型服务器。

此外还有客户端模式。团队如果有自己的工具注册表、自己的嵌入索引或按用户划分的权限过滤,可以把tool_search的execution设为client,并定义自己的搜索参数。这种模式每次搜索多一次往返,因为查找由应用自己执行,好处是用户接入新集成时,团队可以在对话中途开放新工具。

价格方面,谷歌不另收功能费。输入和输出令牌按所调用模型的标准价格计费。开启tool_search会增加一小块固定的输入令牌,模型加载的每个结构在对话其余部分按输入计费,与预先声明的工具相同。谷歌的建议很务实。团队应把最常用的工具预先加载,把偶尔才用到的长尾工具延后,并用自己的流量数据衡量节省效果。支持范围从Gemini 3.6及后续模型开始,包括全部Gemini 4模型,且只在Interactions API中提供。谷歌在文中没有给出令牌节省数字、延迟数字或准确率基准,也没有公布正式版日期。文中还提到,因为搜索调用、搜索结果和函数调用都出现在interaction.steps中,失败的智能体会留下一条可读的记录,方便定位是名称不清、说明太薄还是结构本身导致参数错误。

English

Google put Tool Retrieval into preview in the Gemini Interactions API on November 19, a change that lets an agent keep a large tool library on standby and load a tool’s full parameter schema only when a task needs it.

The launch post is signed by Lucia Loher, a product manager on the Gemini API, and Nora Kassner, a research scientist at Google DeepMind. It names the problem in plain terms. When an agent connects to dozens or hundreds of tools, sending every full schema on every request inflates input token counts, adds latency and lowers tool-selection accuracy as the list grows.

Turning on Tool Retrieval in the Interactions API

Turning the feature on takes two changes. A developer adds a tool_search tool to the request and sets defer_loading: true on each tool to hold back. The model still sees the name and description of every deferred tool, so it knows what exists. The parameter schemas stay out of the prompt until the model asks for a tool by name, at which point the API loads the schema and the model calls the function inside the same request.

Google works through one example in full. A customer writes that order A-1042 arrived damaged and asks for a 40 dollar refund. Inside that single call, the model searches for a function called issue_refund, the API returns its schema, and the model emits the function call with the order number and the amount. All three steps appear in interaction.steps, so a developer can inspect which tools the model considered when a call goes wrong.

Prefix Caching and Remote MCP Servers

Two details in the post will matter to teams with large libraries. Deferred schemas stay out of the start of the prompt, so the cached prefix stays the same from turn to turn when a team uses prefix caching. Tool Retrieval also works with remote MCP servers. Setting defer_loading: true on an mcp_server tool loads every tool that server exposes on demand, so a team can connect a large server without listing its tools one by one.

There is also a client-side mode. A team that keeps its own tool registry, its own embedding index or a per-user permission filter can declare tool_search with execution set to client and define its own search parameters. That mode adds one round trip per search because the app runs the lookup. It also lets a team expose new tools in the middle of a conversation when a user connects an integration.

The problem is not new to this site’s readers. Agents that coordinate many tools were also the subject of the Perplexity Multiagent rollout covered here this week, where up to 16 agents share one job. Tool Retrieval works at a lower level of the same stack. It does not add agents. It cuts the cost of giving one agent a long list of possible actions.

Pricing and Supported Gemini Models

Google is not charging a separate fee for the feature. Input and output tokens are billed at the standard rate for the model called. 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. Google’s own advice is direct. A team saves tokens when the schemas it never loads outweigh the ones it does, and it should measure the result against its own traffic.

Support starts with Gemini 3.6 and later models, including all Gemini 4 models, and only in the Interactions API. Google gives no token saving figure, no latency number and no accuracy benchmark in the post, and it gives no date for general availability. The post points developers to the documentation and to the Gemini developer Discord for feedback while the feature is in preview.

Google’s guidance on which tools to defer is practical. Keep the most-used tools loaded up front, the post says, and defer the long tail of tools that help once in a while. That split keeps common requests fast, because no search step is needed for them, while rare tools stop taxing every prompt. A team can start with that split and adjust it from the step records, moving a tool up front if the model searches for it on most days.

The step records deserve a second look from developers. Because the search call, the search result and the function call all appear in interaction.steps, a failing agent leaves a readable trail. If the model picked the wrong tool, the trail shows whether the name was unclear, the description was thin or the schema itself led to bad arguments. That is debugging information that a single opaque function call does not provide.

Preview status cuts both ways. Teams can build on the feature now and shape it through the Discord channel Google names in the post. They also have to expect the surface to change before general availability, so pinning a model version and keeping tests around tool selection is the cautious path, and it is the path Google’s own measurement advice points toward.

The same week also brought results far from developer tooling, including fossil teeth that extend the record of Homo erectus in mainland China, which is a reminder that the Interactions API work competes for attention with science news on its own merits, namely lower token bills for large agent libraries.

本报道的其他版本也刊登在 News Today World, Manhattan Mogul, Newsy USA, The American Newsroom, Revista Minutos 和 Le Miroir Francais。

More from 最新消息More posts in 最新消息 »
More from 科技More posts in 科技 »

Be First to Comment

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注