Google Adds Mid-Session Instruction Updates to the Gemini API While Preserving Caching
Google has launched a public preview for the Gemini API that lets developers update system instructions and custom function tools mid-session through the Interactions API while preserving the cache of previously supplied prompt tokens. Updates are appended to the history as system_input entries, with newer instructions taking precedence in the event of a conflict, although older instructions cannot be deleted. The feature is available only through the v1beta Interactions API for gemini-4-carbon, gemini-4-neon, and gemini-4-hydrogen. It does not support MCP servers, built-in tools, generateContent, or agent interactions, and actual function permissions must still be authorized by the backend.
Why read this
AI score 65
The new mechanism allows agent rules to be adjusted mid-session while retaining cache reuse, and also clarifies the boundaries of append-only instructions, tool support, and backend authorization.
Topics
Body
Google introduced a public preview on December 3, 2026 that lets Gemini API developers update system instructions and function tools mid-conversation without invalidating cached prompt tokens. The capability runs through the Interactions API, adding system-level controls for agents whose rules and permissions change during a session.
Long-running agents can span dozens or hundreds of turns, during which spending limits, account permissions and available functions may change. Developers previously had two workarounds: inserting instructions into user messages preserved the cache but lacked top-level system authority and could be imitated by users, while rewriting the system instruction or tools list invalidated the cache. The latter forced the model to reprocess the full conversation history, adding cost and latency. The new system_input step carries the same authority as the top-level system instruction and takes precedence over user messages while earlier turns remain cached.
To make an update, the application chains the new turn with previous_interaction_id, allowing the server to retrieve stored conversation history rather than requiring the application to resend it. The request format places one system_input step immediately before user_input and keeps the top-level system_instruction unchanged. Because the new step is appended at the current turn boundary, all preceding tokens remain identical, preserving the cached prompt prefix.
Each update becomes a separate history step rather than replacing earlier instructions. The original system instruction and all previous system_input steps remain in context; nonconflicting rules continue together, while the model favors the newest instruction when rules conflict. When reversing a rule, Google recommends stating what changed and telling the model to ignore the earlier instruction, since previous steps cannot be removed. Retrieved interactions list these steps chronologically alongside user input, model output and tool changes, creating an inspectable record for debugging.
Google’s infrastructure example shows the intended sequence: an assistant troubleshooting a latency spike receives a new production deployment freeze, with instructions to recommend read-only diagnostics and prevent further rollouts. A user then asks for the command to deploy a release. The example’s model reply declines the release and offers diagnostic checks, applying the new rule without resetting the earlier session.
Applications keep sending the original top-level tools list, including functions that have been disabled, and use removed_tools and added_tools on system_input to change the active set. Changes persist until a later update. When both fields appear together, removals are processed before additions, allowing a function definition to be replaced. Only custom function tools are supported; MCP servers and built-in tools such as Google Search and code execution are not.
These fields steer model behavior; they do not enforce application permissions. Google advises authorizing every function call on the backend before execution and keeping untrusted external or end-user content out of system_input. That distinction is central to uses such as enabling write tools after authentication, disabling functions during a downstream outage or expanding a large tool catalog only when a task requires it.
Preview Availability and Token Pricing
The preview requires the v1beta Interactions API, and its API surface may change before general availability. The documentation lists support for gemini-4-carbon, gemini-4-neon and gemini-4-hydrogen; other models return HTTP 400. It is limited to model interactions, leaving generateContent requests and agent interactions unsupported.
Malformed requests can also fail with HTTP 400, including a standalone system_input, one sent during a function-result loop, or later requests that drop a removed function from the original top-level tools list. Added tools must similarly remain outside that top-level list rather than being declared again on subsequent turns.
There is no separate fee for mid-conversation instructions. Tokens in system_input are billed at the called model’s standard input-token rates, while earlier turns remain eligible for cached-token rates. Google says Gemini Enterprise Agent Platform support is coming soon.
The preview gives long-running agents an inspectable way to change policy and capabilities as conditions shift while retaining conversational context. Its main constraint is the append-only design: cached history survives an update, but old instructions remain present, and backend authorization—not the revised tool list—ultimately determines which actions can execute.
AI Trends