3 min Devops

Gemini API adjusts agent rules without breaking the cache

Gemini API adjusts agent rules without breaking the cache

Through the Interactions API, Google lets you adjust system instructions and tools mid-conversation. The prompt cache remains intact. The feature is available in public preview for all Gemini 4 models and incurs no separate charge.

AI agents that run for extended periods often go through dozens or even hundreds of consecutive interaction steps (turns). Along the way, rules, permissions, and available tools change. Until now, a developer could not give the model a new system instruction or change tools without invalidating the cache. Google wants to change that.

The new capability revolves around a `system_input` step. This can be included in every turn, immediately before the `user_input`. According to Google, such a step has the same authority as the original system instruction and takes precedence over user messages. Meanwhile, previous turns remain cached.

Until now, developers have relied on two workarounds. They either embedded new instructions in a user message, which carry less weight and users can mimic, or rewrote the system instruction, forcing the model to reprocess the entire conversation history. That costs money and introduces additional latency.

Adding and removing tools

Tools can also be modified during a session. Tool declarations appear at the beginning of the prompt, so a modified list breaks the cache. Google therefore recommends keeping the top-level tool list consistent for each turn and implementing changes via `added_tools` and `removed_tools`. If both are used in a single step, the API processes the removals first. This allows a tool definition to be replaced immediately.

Google provides the example of a support agent who loses a refund tool as soon as an account is under review and receives an escalation tool in its place. Other scenarios include: granting write permissions only after authentication, temporarily disabling a tool when a dependent service goes offline, or expanding a large tool catalog step by step. Only function tools are supported; MCP server tools are not yet supported.

If instructions conflict, the model chooses the most recent one. Rules covering different topics remain active at the same time. Google does warn, however, that `system_input` is a control mechanism and not a security layer. Applications must still authorize every function call in the backend. Unreliable content does not belong in `system_input`.

Google does not charge any additional fees for this new feature. Tokens in `system_input` steps are subject to the standard input rate of the selected model; previous turns remain eligible for cached-token rates. The preview is available via the v1beta endpoint of the Gemini API. Support for the Gemini Enterprise Agent Platform will follow shortly.

Tip: “MCP is just an API,” and that’s exactly the problem with Gemini Enterprise