Developer toolsNotable

Gemini API lets agents change system instructions and tools mid-session without losing the prompt cache

A new system_input step in the Interactions API adds rules and swaps function tools at any turn, while earlier turns stay cached. It is in public preview for all Gemini 4 models.

Promptea Editorial4 min read

Google on Thursday, December 3, released a preview feature in the Gemini API that targets a specific cost problem in long-running agents: changing the rules partway through a session. Until now, a developer who rewrote the system instruction or the tool list between turns invalidated the prompt cache, so the model reprocessed the whole conversation. According to Google's announcement, the new mechanism avoids that.

The feature is in public preview in the Interactions API (the v1beta endpoint) and, per Google, works with all Gemini 4 models. Google says support in Gemini Enterprise Agent Platform will come later. There is no separate fee: tokens in the new step are billed at the model's standard input rate.

How it works

A developer continues a conversation by passing the previous turn's ID in previous_interaction_id and placing a new system_input step directly before the user_input step. The top-level system_instruction stays identical on every turn, so the prefix the cache depends on does not change. Because the new step is appended at the current turn boundary, everything before it can still be served from cache.

Google describes the following behaviour:

  • A system_input step carries the same authority as the top-level system instruction and takes precedence over user messages.
  • Each step stays active for the rest of the session. Rules on different topics accumulate; when a newer instruction conflicts with an earlier one, the model favours the most recent.
  • One system_input step is allowed per turn, and it can contain text, tool changes, or both.
  • Retrieving an interaction returns system_input steps in order next to user and model steps, which gives an audit trail of when each rule entered the session.

Changing tools without breaking the cache

Tool declarations sit at the start of the prompt, so editing the top-level tools list also breaks the cache. Google's recommendation is to keep that list fixed and use two new fields inside system_input: added_tools and removed_tools. Changes persist until a later step changes them again. When both fields appear in one step, removals are processed first, which lets a developer replace a tool definition in place.

Google's example is a support agent that starts with a store-hours lookup and a refund function. When an account enters billing review, the app removes the refund tool, adds an escalation tool and includes a short note so the model can explain why refunds are unavailable. The limitation: only function tools can be updated this way. MCP server tools are not supported in this preview.

Why the old workarounds were costly

Google names the two patterns developers used before. One was to send new rules as a user message, which keeps the cache but gives the rules less weight and lets a user try to imitate them. The other was to rewrite the system instruction or tools, which restores authority but forces the model to reprocess the full history, adding cost and latency. The new step tries to provide the authority of the first without the cost of the second.

Google has not published measurements of how much cost or latency this saves, or of how reliably the model follows a late instruction over a long session. Both depend on session length and cache hit rate, so teams will need to check them on their own workloads.

What changes for prompting and agent design

For anyone building agents on Gemini, the practical shift is that the system prompt no longer has to describe every state the session might reach. A stable base instruction can cover identity and permanent policy, while situational rules such as a deployment freeze, an account's entitlements or a spending limit can be added when they become true. Tool sets can also start small and grow as a task needs them, instead of declaring a large catalog up front.

Two points deserve care. First, because newer instructions win conflicts, ordering now matters: a rule added late can quietly override an earlier one. Teams should keep system_input text short and specific, and test conflicting sequences. Second, Google states plainly that system_input, added_tools and removed_tools steer behaviour but are not security controls. Every function call should still be authorized on the backend, and untrusted or end-user content should be kept out of system_input, since text placed there inherits system-level authority.

Context

Long agent sessions have made prompt caching one of the main levers on API cost, and providers have been adding ways to keep cache prefixes stable. This feature applies that logic to the instructions themselves. It is a preview on one API surface, so field names and behaviour may still change before general availability.

Why this matters

  • Agents that run for dozens or hundreds of turns can update rules and tools without paying to reprocess the whole history, according to Google.
  • Late rules get system-level authority instead of being sent as user messages that carry less weight.
  • Because newer instructions win conflicts and the feature is not a security boundary, backend authorization and careful instruction ordering still matter.

Key takeaways

  • Public preview, December 3, 2026: system_input steps in the Gemini Interactions API (v1beta), for all Gemini 4 models.
  • added_tools and removed_tools update function tools mid-session; MCP server tools are not supported yet.
  • No separate fee: system_input tokens bill at standard input rates, and earlier turns stay eligible for cached-token rates.
Tags:
  • gemini-api
  • prompt-caching
  • system-prompts
  • agents
  • tool-calling
Companies:
  • Google
Models:
  • Gemini 4