Gemini API keeps the cache when agent instructions change mid-session
Google has released a system_input step in preview that lets developers add new system instructions and change tools at any turn. Google said the step carries the same authority as the top-level system instruction.
Google announced the feature in a blog post on 3 December. Until now, developers had two workarounds when an agent’s rules changed mid-session. They could send the new instruction as a user message, but it then lacked the authority of a system instruction, and users could also try to imitate it. Rewriting the system instruction or tool list, on the other hand, made the cache useless. The model had to reprocess the entire conversation history, which added cost and latency.
The prompt cache stores the already processed beginning of the prompt so that it does not have to be computed again. Developers therefore add the system_input step to the current turn just before the user message and send the top-level system instruction unchanged on every turn. This keeps all earlier tokens identical. Google said the step carries the same authority as the top-level system instruction and takes precedence over user messages.
Instructions accumulate rather than replace one another. Each step stays in force until the end of the session, and when instructions conflict, the model favours the most recent one. Google recommends reversing a rule by telling the model what changed and instructing it to ignore the earlier instruction, since earlier steps cannot be removed, Unite.AI reported. In Google’s example, the assistant is told that production deployments are frozen. When the user then asks for a deployment command, the model refuses and offers diagnostics.
Developers change tools in the same step using the added_tools and removed_tools fields, while the top-level tool list stays unchanged. If a removed function is later dropped from the top-level list, the request fails with an HTTP 400 error, Unite.AI reported. Added tools must not be declared there again either. The same error occurs if system_input is sent on its own or during a round of function results. The changes apply only to the developer’s own function tools. MCP servers are not supported, nor, according to Unite.AI, are built-in tools such as Google Search.
Google pointed out that system_input and the tool fields steer the model but do not enforce permissions. Applications must authorise every function call on the backend before executing it and keep untrusted external or end-user content out of the system_input step.
Google’s blog said the feature is in public preview for all Gemini 4 models in the v1beta version of the Interactions API. Support for Gemini Enterprise Agent Platform is coming soon. Unite.AI reported that the API may still change and that the documentation lists gemini-4-carbon, gemini-4-neon and gemini-4-hydrogen as supported models. Other models return an HTTP 400 error. The feature works only when a model is called through the Interactions API; it does not support agent calls or generateContent requests. There is no separate fee: system_input tokens are billed at the standard input rate, and earlier turns can still qualify for cached pricing.
Read more: How an agent works · Agent map