Blog / Latest in AI

Latest in AI

Google lets Gemini API apps change rules mid-chat without losing the cache

Unicorn News Desk ·

Abstract chain of glowing blocks with a new differently colored block added at the end

Key facts

Announced
December 3, 2026
Status
Preview, in the Gemini API's Interactions API
New mechanism
A system_input step sent before user_input at any turn
Authority
Same as the top-level system instruction; overrides user messages
Tool changes
added_tools and removed_tools; function tools only, not MCP server tools

Google has put a feature into preview in the Gemini API that lets developers change an AI agent’s system instructions and tools partway through a conversation without invalidating the prompt cache. The company announced the change on December 3, 2026, and it works through the Gemini API’s Interactions API. Google frames it as a fix for long-running agents whose rules, permissions and available tools shift during a session.

The update is small in surface area, one new input type and two tool fields, but it targets a real cost problem for anyone running multi-turn agents. Until now, Gemini developers had to choose between keeping the cache and giving the model properly authoritative instructions.

What Google added to the Gemini Interactions API

The Interactions API now accepts a system_input step at any turn. That step can carry new system instructions, tool changes, or both. According to Google, it “carries the same authority as your top-level system instruction and takes precedence over user messages, while earlier turns stay cached”.

The announcement is written by Trey Nguyen, product manager for the Gemini API, and Daniel Kyme, product manager at Google Cloud. Google says the goal is to let agents “adapt to new rules and tools mid-session without re-reading the entire conversation or driving up costs”.

ItemWhat Google states
StatusPreview, in the Gemini API via the Interactions API
Mechanismsystem_input step placed directly before user_input
FrequencyOne system_input step per turn
ContentsText, tool updates, or both
Tool fieldsadded_tools and removed_tools
Supported toolsFunction tools only; MCP server tools not yet supported
Conflict ruleThe model favours the most recent instruction
API version in examplesv1beta, with the model gemini-4-neon

Why changing instructions used to break the cache

Prompt caching lets a provider reuse the work it already did on the start of a prompt, so repeated content such as a system prompt, tool definitions or a long conversation history is billed at a discount and processed faster. The catch is that only a prefix can be cached. Each token depends on every token before it, so the cache stops at the first difference, and a single changed token early in the prompt invalidates everything after it.

System instructions are processed before the rest of the prompt, and Google notes that tool declarations also sit at the start of the prompt. That placement is what makes them cache-friendly when they stay fixed, and costly when they change. Google describes the two workarounds developers have used:

  • Putting new rules in a user message. This keeps the cache, but such messages “don’t carry the same weight” as top-level system instructions, and they let users try to imitate them.
  • Rewriting the system instruction or tools. This keeps the rules authoritative but invalidates the prompt cache, so the model reprocesses the whole conversation history, adding cost and latency.

Google says long-running agents “often work across dozens, if not hundreds, of turns”. At that length, reprocessing the full history each time a rule changes adds up. A third-party caching guide notes that long multi-turn conversations and many tool definitions are among the workloads that benefit most from caching, while caching does not make output tokens cheaper or faster.

Isometric row of uniform tiles with new tiles added only at the end
Prompt caching reuses an identical prefix, so additions at the end keep earlier work reusable. · Illustration

How a system_input step works

To send an instruction mid-conversation, a developer passes the previous turn’s ID in previous_interaction_id and places a system_input step directly before the user_input in the input array. The top-level system_instruction should stay unchanged across turns so the prompt prefix remains valid in the cache.

Google’s example is an infrastructure troubleshooting assistant. On the second turn, the app injects a rule that “a production deployment freeze is now active” and tells the model to recommend read-only diagnostics, and the user then asks for a deploy command. In Google’s sample output, the model replies that a freeze is active and offers checks instead.

Google describes several behaviours developers need to plan around:

  • Each system_input is appended to the conversation history as its own step and stays active for the rest of the session, alongside the top-level instruction.
  • Rules covering different topics remain in effect together.
  • When a newer system_input conflicts with an earlier instruction, the model favours the most recent one.
  • Because the step is appended at the current turn boundary, all preceding tokens stay identical from turn to turn and reuse the prompt cache.

There is also an audit benefit. Retrieving an interaction with client.interactions.get returns each system_input step in order alongside user_input and model_output, which Google says makes multi-turn agent traces “straightforward to audit and debug”.

Swapping tools during a session

The same mechanism covers tools. Because changing the top-level tools list between turns breaks the prompt cache, Google recommends leaving that list identical on every turn and using added_tools and removed_tools inside system_input to change which functions the model can call.

Google’s example is a support agent that starts with get_store_hours and issue_refund. On the next turn, the app tells the model the account is under billing review, removes issue_refund and adds create_escalation_ticket, while the top-level tools list stays the same.

The main limit in this preview: only function tools can be updated through added_tools and removed_tools, not MCP server tools. MCP, the Model Context Protocol, is a standard way to connect models to external tool servers, so agents built around MCP servers cannot yet use this route for tool changes.

Abstract panel of tool icons with one removed and one added around a central node
Apps can add or withdraw function tools as a session changes. · Illustration

How it compares with Anthropic’s approach for Claude

Google is not the first to tackle this. Anthropic’s Claude documentation describes “mid-conversation system messages”: instead of editing the top-level system field, developers append a message with role "system" at the point where the new instruction applies, so the cached prefix stays the same and the instruction is still treated as a system instruction rather than user text. In Anthropic’s Managed Agents product, the equivalent is a system.message event that applies to that turn and all later ones.

Anthropic’s tool version uses tool_addition and tool_removal blocks inside a system message, with the full tool set declared up front so the tools array never changes. Anthropic labels mid-conversation tool changes as beta. The two designs line up closely, with some differences visible in the documentation:

  • MCP tools. Claude’s blocks can reference MCP connector tools individually or as a whole toolset; Google’s preview supports function tools only.
  • Defining new tools mid-session. With a separate beta header, Claude’s tool_addition can carry a tool’s full definition, letting developers introduce a tool unknown at the start of the conversation. Anthropic lists exceptions: during the beta, computer use and browser use tools cannot be defined in a message.
  • Error handling. On Claude, referencing a tool name not declared in the tools array returns a 400 error. Google’s announcement text available for this article does not describe equivalent error behaviour.

The shared premise is the same in both: anything that changes the start of the prompt breaks the cache, so new rules and tool changes are appended at the end instead. Anthropic notes that the tools array sits even earlier in the hashed request prefix than the system field.

What it means for builders, and the open questions

For teams running long agent sessions on Gemini, the practical change is that permission changes, policy flags and tool swaps no longer force a choice between authority and cost. A billing hold, a deployment freeze or a role change can be expressed as a system-level rule at the moment it happens, rather than as a user message the model may weigh less or that a user might imitate.

Some cautions follow from the sources:

  • It is a preview. Google labels the feature preview, and its examples use the v1beta API version. Behaviour and field names may change before general release.
  • Interactions API only. The announcement places the feature in the Interactions API. It does not say the feature is available in other Gemini endpoints, and Google Cloud’s system-instruction documentation for the Gemini Enterprise Agent Platform describes a single system instruction that applies to the entire request. Developers on that platform should check whether and when it arrives there.
  • Instruction accumulation. Every system_input stays active for the rest of the session, and conflicts resolve toward the newest instruction. Over hundreds of turns, teams will need to track which rules are still in force.
  • Cache discipline still matters. The savings depend on keeping the top-level system instruction and tools list byte-for-byte identical across turns. A third-party guide warns that small changes such as a timestamp in the system prompt or tool definitions in a different order break caching for everything that follows.
  • No independent numbers. Google says the feature avoids added cost and latency but publishes no measurements in its announcement. The same guide notes Gemini uses implicit caching by default, with explicit caches optional, and how this feature interacts with each mode is not spelled out in the sources.

System instructions also remain part of the overall prompt and are subject to standard data use policies, according to Google Cloud’s documentation. Mid-session rules should be treated with the same care as the original system prompt.

What to watch next

The clearest gaps to watch are MCP server tool support, which Google says is not yet available, and a move from preview to general availability. Anthropic’s documentation already shows MCP references and inline tool definitions in beta, which suggests the direction this kind of feature can take. Independent measurements of cache hit rates and cost savings on real multi-turn Gemini agents would also help settle how much the change saves in practice.

Frequently asked questions

What are mid-conversation instructions in the Gemini API?

They let developers send new system rules or tool changes at any turn of a conversation, through a system_input step in the Interactions API. Google says the step carries the same authority as the top-level system instruction and earlier turns stay cached.

Is the feature generally available?

No. Google says it is available in preview in the Gemini API through the Interactions API, and its code examples use the v1beta API version.

Can I add or remove MCP server tools mid-conversation?

Not yet. Google says only function tools can be updated through added_tools and removed_tools, not MCP server tools.

How does this compare with Anthropic's Claude?

Anthropic's documentation describes a similar approach: a role 'system' message appended mid-conversation plus tool_addition and tool_removal blocks, in beta. Claude's version can also reference MCP connector tools, which Google's version does not yet support.

Does this lower costs?

Google says it avoids re-reading the whole conversation and driving up costs, because earlier turns keep hitting the prompt cache. Google has not published cost figures, and no independent measurements are available yet.