Why Large Agent Tool Lists Hurt Both Latency and Accuracy
Connect an AI agent to CRM lookups, billing actions, Jira tickets, GitHub repos, and database queries, and your prompt quickly balloons with 50 to 200 JSON function definitions on every request.
That creates two problems at once: you pay input token fees for parameter schemas the model never calls on that turn, and crowded candidate lists increase wrong argument guesses.
Instead of forcing developers to build brittle intent routers from scratch, Google's Gemini Interactions API lets you leave lightweight names and descriptions visible while holding back heavy parameter schemas until the model explicitly pulls them.
- No separate billing surcharge—standard token rates apply only to schemas actually fetched into context.
- Preserves prompt prefix caching because loaded tool schemas append later in conversation steps rather than mutating the top prefix.
- Supports client-side registries ("execution": "client") if your app filters tools per user permission or local vector index.
Keep your 3–5 highest-frequency functions undeferred so routine turns avoid any search step, and set defer_loading: True on the remaining long tail.
Static Function Calling vs. Gemini Tool Retrieval
Inside a single server-side Interactions API call, Gemini runs three transparent steps visible in interaction.steps: tool_search_call, tool_search_result, and the final function_call—without forcing extra network round trips from your backend.
If you wire remote Model Context Protocol (MCP) servers, setting defer_loading: True on the mcp_server block loads individual MCP tool definitions on demand instead of dumping an entire server catalog into turn one.
| Capability | Standard Function Declarations | Gemini Interactions Tool Retrieval |
|---|---|---|
| Initial Prompt Payload | All tool names, descriptions, and schemas | Names & short descriptions; schemas deferred |
| Prefix Caching Impact | Breaks if tool list shifts per user | Prefix stays stable; loaded schemas append cleanly |
| Remote MCP Servers | Loads full tool surface up front | Set defer_loading: true on mcp_server |
| Custom Auth Filtering | Rebuild prompt template per session | Set "execution": "client" to query your index |
Working Python Implementation (Server-Side & Client-Side)
Using server-side search requires just two additions to google-genai's Interactions client: declare {"type": "tool_search"} inside tools and tag deferred functions with "defer_loading": True.
For enterprise apps with per-user permissions or internal tool registries, swap "execution": "client" on tool_search so Gemini calls your custom search function and injects matching schemas via previous_interaction_id.
Either approach avoids re-building sprawling prompt strings when integrations grow—new plugins simply register lightweight descriptions until needed at runtime.
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"],
},
},
]
interaction = client.interactions.create(
model="gemini-4-hydrogen",
input="Order A-1042 arrived damaged. Refund 40 dollars.",
tools=tools,
)