Skip to content
ExplainedCode

Gemini API can drop tools mid-chat, but keep your original list

Gemini API adds mid-conversation rules and tool changes without busting the cache. Delete a removed tool from the original list and later turns fail.

By DC Team · · 5 min read

Official Gemini logo beside the headline Change the rules. Keep the conversation. A connected conversation diagram shows a new rule added while earlier messages stay intact.

The Gemini API can now change an agent's instructions and function tools midway through a conversation while preserving its prompt cache. But the most tempting cleanup can break your integration: after disabling a function, you must keep sending its original definition in the top-level tool list. Removing it there causes HTTP 400 on later turns. Disable the function through the new update step instead. Google's tool-update rules.

Google announced the feature on December 3 as a public preview through the Interactions API's v1beta endpoint. It addresses a practical agent problem: a session can outlive the rules and permissions it started with. A customer authenticates, an account enters review, or a production freeze begins. The application needs to communicate that change without rebuilding the prompt prefix. Launch announcement.

Our take: the useful upgrade is making changes explicit in the conversation's execution history. Adopt it where your application already has changing permissions, but keep an immutable baseline tool list alongside the current permissions. Those two things now have deliberately different jobs.

What the Gemini API actually changes

The new system_input step appends instructions at the current turn boundary with the authority of a system instruction, ahead of user messages. Earlier conversation tokens remain unchanged and eligible for cached pricing. The old alternatives were weaker user-message instructions or changes to the initial system prompt and tools that invalidated the cache. Google's explanation.

That distinction matters for a support assistant. Suppose the assistant starts with order lookup and refund functions. Halfway through the conversation, the account enters billing review. Your application wants order lookup to continue, refunds to stop, and the assistant to explain the restriction. A new instruction plus removed_tools can communicate that transition without replacing everything the model has already read.

The release notes explicitly list gemini-4-carbon, gemini-4-neon and gemini-4-hydrogen. The guide limits this feature to model interactions through Interactions, excluding generateContent and managed agent interactions. This is a specific API capability, so verify your actual request route before treating it as an automatic upgrade. Release notes, supported models and limitations.

A removed function still belongs in your baseline

The surprising rule comes from how the API validates stored history. Keep passing the original tools array when chaining requests with previous_interaction_id, including definitions for functions disabled later. Conversely, functions introduced through added_tools should stay out of that original array. Redeclaring an active added function there also produces HTTP 400. Tool-update contract.

Here is an adapted Python example for a disposable test session. It deliberately makes three turns: establish the baseline, disable refunds, then continue using the same baseline. Install Google's google-genai SDK and configure your API key as described in its quickstart. This example follows the documented request schema; we have not run it against a paid model.

from google import genai

client = genai.Client(http_options={"api_version": "v1beta"})
model = "gemini-4-neon"
baseline = [{
    "type": "function",
    "name": "issue_refund",
    "description": "Refund an order.",
    "parameters": {
        "type": "object",
        "properties": {"order_id": {"type": "string"}},
        "required": ["order_id"],
    },
}]
system = "You are an order support assistant."

first = client.interactions.create(
    model=model, tools=baseline, system_instruction=system,
    input="Say hello. Do not call any tools.",
)
second = client.interactions.create(
    model=model, tools=baseline, system_instruction=system,
    previous_interaction_id=first.id,
    input=[
        {
            "type": "system_input",
            "content": [{"type": "text", "text":
                "Refunds are paused. Explain the restriction."}],
            "removed_tools": [
                {"type": "function", "name": "issue_refund"}
            ],
        },
        {"type": "user_input", "content": [
            {"type": "text", "text": "Refund order 12345."}
        ]},
    ],
)
third = client.interactions.create(
    model=model,
    tools=baseline,  # Keep the original definition here.
    system_instruction=system,
    previous_interaction_id=second.id,
    input="What options remain available?",
)
print(third.output_text)

Do not wire this demonstration to a real refund executor. In your test environment, inspect the second turn's stored steps, then confirm that the third request succeeds and the disabled function remains unavailable. A two-turn demo misses the later-history validation trap.

For application design, keep the baseline definitions fixed for the chain and derive current permissions separately. Record which update changed those permissions and when. That gives an incident reviewer a meaningful question to answer: what was allowed when the action was requested?

The update cannot land in the middle of a tool loop

There is a timing catch too. Google permits at most one system_input per turn, directly before a user_input step. It cannot arrive alone or with a function_result during a function-calling loop. Invalid placement returns HTTP 400. Text content must be text only; a step without text must add or remove tools. Placement rules.

Imagine a production freeze starting while a deployment function is pending. This feature gives you a place to update the assistant at the next permitted turn. It does not establish that an already-dispatched deployment is canceled. Our recommendation is to check the current freeze state in the deployment backend before execution, even if the model requested the action earlier.

Google makes the same broader boundary explicit: these fields steer model behavior, and applications should authorize every function call on the backend. It also warns against putting untrusted external or user content into system_input. Launch guidance.

The current tool updates support custom functions only, excluding MCP servers and built-in tools such as Google Search. Another easy-to-miss limitation: tool_choice applies only to the initial tool list. Do not assume that a mode configured there also constrains a function introduced later. Tool rules, limitations.

What preserving the cache could save

There is no separate feature fee. New update tokens cost the model's standard input rate, while earlier turns remain eligible for cached-token rates. Google does not promise that every eligible prefix will receive a cache hit. Pricing explanation.

For a concrete comparison, the current Neon standard table lists $3 per million input tokens and $0.15 per million cached tokens, with implicit caching only. Official pricing.

Our illustrative calculation assumes a 100,000-token prior conversation and a 200-token update. It isolates input processing for one subsequent request:

Input componentReprocessed prefixCache-hit prefix
100,000 earlier tokens$0.3000$0.0150
200 new update tokens$0.0006$0.0006
Input subtotal$0.3006$0.0156

The difference is $0.285 per request under those assumptions. At 10,000 otherwise identical requests, that becomes $2,850. This is arithmetic, not a measured production bill. It excludes the new user message, output and thinking tokens, tools, and every request that misses the cache.

Use that calculation to decide whether an experiment is worth running. To claim actual savings, compare the same workload with and without prefix changes and keep failed requests in your totals. Saving input cost on a request that must be retried is not the outcome your budget needs.

What to do

Start with one workflow where permissions change during a session, such as pausing refunds. Capture the baseline tool definitions and keep them stable across the chain. Add changes through the update step, with a short explanation the assistant can use when answering the customer.

Then run these acceptance checks before enabling real actions:

  1. Continue past the change. Exercise at least three turns and verify that the original list survives the disabled-function update. Inspect the stored interaction for the ordered system_input, user input and model output steps. Google's retrieval example shows that audit surface.
  2. Reverse a rule explicitly. Earlier instructions remain in context; a newer conflicting instruction is favored, but does not delete the old one. State what is being reversed and test both the paused and restored cases. Instruction-combination rules.
  3. Reject unauthorized calls in your executor. Recheck account and operational permissions when a function is about to run. Test a stale request that was created before permission changed.
  4. Measure the real tradeoff. Track input usage, cache use, errors and completed tasks. Keep the preview behind a reversible application setting because Google says the API surface may change before general availability. Preview notice.

For teams also building spoken agents, our Gemini Live upgrade analysis covers a separate completion-state problem. Here, the immediate decision is whether your request builder can preserve its original configuration while the application's permissions evolve. Check that third turn before declaring the migration finished.