aifollow.news
返回 Google AI 官方博客
Google AI 官方博客· · 原发布时间 AI 评分47

Gemini API 推出工具检索预览,按需加载工具参数

AI 辅助摘要

Gemini API 的 Interactions API 已提供 Tool Retrieval 预览:智能体可先保留工具名称和描述,在需要调用时才加载完整参数,以减少大型工具库反复占用的输入 token。该功能支持 Gemini 3.6 及更新模型;不单独收费,但检索和已加载参数仍计入模型输入 token。

正文 · 原文

该语言的正文暂不可用,当前显示已有版本。

Introducing Tool Retrieval in the Gemini API

Nov 19, 2026

|

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.

Lucia Loher

Product Manager, Gemini API

Nora Kassner

Research Scientist, Google DeepMind

Share

Your browser does not support the audio element.

Listen to article

This content is generated by Google AI. Generative AI is experimental

Voice

Speed

Voice

Speed

0.75X

1X

1.5X

2X

Today we're launching Tool Retrieval in the Gemini API, available in preview in the Interactions API.

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.

How it works

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.

from google import genai

client = genai.Client()

tools = [

{"type": "tool_search"},

{

"type": "function",

"name": "issue_refund",

"description": "Refund an order to the original payment method.",

"defer_loading": True,

"parameters": {

"type": "object",

"properties": {

"order_id": {"type": "string"},

"amount": {"type": "number"},

},

"required": ["order_id", "amount"],

},

},

# ... 50+ other deferred functions (leave frequent tools undeferred)

]

interaction = client.interactions.create(

model="gemini-4-hydrogen",

input="Order A-1042 arrived damaged. Please refund 40 dollars.",

tools=tools,

)

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:

"steps": [

{

"type": "tool_search_call",

"id": "tsc_7f2a",

"arguments": {"function_names": ["issue_refund"]},

"signature": "..."

},

{

"type": "tool_search_result",

"call_id": "tsc_7f2a",

"result": [{"type": "function", "name": "issue_refund", "parameters": {...}}],

"signature": "..."

},

{

"type": "function_call",

"id": "fc_91c3",

"name": "issue_refund",

"arguments": {"order_id": "A-1042", "amount": 40}

}

]

From here it's normal function calling: your code runs the refund and sends back a function_result.

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 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 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.

How client-side retrieval works

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:

tools = [{

"type": "tool_search",

"execution": "client",

"name": "search_tools",

"description": "Search the internal tool registry for functions.",

"parameters": {

"type": "object",

"properties": {"query": {"type": "string"}},

"required": ["query"],

},

}]

# When the model emits a function_call for "search_tools",

# return matching {"type": "function", ...} schemas in function_result:

followup = client.interactions.create(

model="gemini-4-hydrogen",

previous_interaction_id=interaction.id,

tools=tools,

input=[{

"type": "function_result",

"name": "search_tools",

"call_id": step.id,

"result": my_registry.search(**step.arguments),

}],

)

How pricing and supported models work

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 works with Gemini 3.6 and later models, including all Gemini 4 models, in the Interactions API.

How to get started

Read the documentation — Full setup guide with examples

Compare Gemini models — Find the best model for your use case

Join the discussion on Discord — Share feedback with the team

Get the latest news from Google in your inbox

Sign up for our newsletters with product updates, event information, special offers, and more.

Done. Just one step more.

Check your inbox to confirm your subscription.

You can also subscribe with a different email address.

Posted in:

发现内容有误?提交纠错

本文目录