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.
Official Google AI Blog Python example using tool_search and defer_loading in Gemini Interactions API
Official Gemini Interactions API snippet showing tool_search and defer_loading: True (source: blog.google).
Builder Note

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.

Illustrative Context Overhead: 60-Tool Agent Turn (Input Schema Tokens) Sending all full JSON schemas vs. deferring 55 long-tail schemas until retrieved
All 60 Schemas Loaded Up Front~9,200 tokens
Tool Retrieval (5 Core + 3 Fetched)~1,850 tokens (-80%)
CapabilityStandard Function DeclarationsGemini Interactions Tool Retrieval
Initial Prompt PayloadAll tool names, descriptions, and schemasNames & short descriptions; schemas deferred
Prefix Caching ImpactBreaks if tool list shifts per userPrefix stays stable; loaded schemas append cleanly
Remote MCP ServersLoads full tool surface up frontSet defer_loading: true on mcp_server
Custom Auth FilteringRebuild prompt template per sessionSet "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.

python
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,
)