Developers building AI agents can now change the rules and tools those agents work with in the middle of a session, without wiping out the cache that keeps costs down. Google announced the change this week, saying mid-conversation system instructions and tool changes are available in preview in the Gemini API through the Interactions API.

The problem Google is targeting comes up often with agents that run for a long time. A single session can stretch across dozens of turns, or even hundreds. Over that span, the rules, permissions and available tools tend to change. Until now, adding a new system instruction or updating tools invalidated the prompt cache, which meant the model had to reprocess the whole conversation.

Developers had two common workarounds, and Google said both had drawbacks. Some sent new instructions as a user message to keep the cache intact. But those messages do not carry the same weight as top-level system instructions, and users can try to imitate them. Others rewrote the system instruction or changed the tools, which invalidated the cache and forced the model to reprocess the entire history, adding cost and latency.

The new approach adds a system_input step. Developers can send one at any turn that includes a system instruction or tool changes. Google says it carries the same authority as the top-level system instruction and takes precedence over user messages, while earlier turns stay cached.

How the new step works

How do you update Gemini agent instructions mid-conversation?

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 user_input in the input array. The top-level system_instruction should stay the same across turns so the prompt prefix remains valid in the cache.

Each system_input step 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. If a newer system_input conflicts with an earlier one, the model favors the most recent instruction.

Retrieving an interaction shows each system_input step in order, next to user input and model output. Google says that makes multi-turn agent traces easier to audit and debug. Because the step attaches at the current turn boundary, all earlier tokens remain identical from turn to turn and can reuse the cache. Developers can send one system_input per turn, containing text, tool updates or both.

Changing tools without breaking the cache

Does changing agent tools mid-conversation break the prompt cache?

Tool declarations sit at the start of the prompt, so changing the top-level tools list between turns breaks the cache. Google recommends keeping the same tools list on every turn and using added_tools and removed_tools inside the system_input step to change which functions the model can call.

For now, that tool-update path covers function tools only. It does not support MCP server tools. When a single step includes both fields, the API processes removed_tools first, which lets a developer replace a tool definition in place. Google also suggests adding a short text note when removing a tool, so the model can explain to users why an action is unavailable.

Google cautioned that these steps steer model behavior but are not security controls. Applications should still authorize every function call on the backend before running it, and they should keep untrusted external or end-user content out of system_input.

The company listed several uses, including applying rules discovered partway through a conversation, such as workspace settings, account entitlements or spending limits. Developers could also enable write tools after authentication and remove them when a session returns to read-only review. Another example is disabling a tool when a downstream service goes offline, then restoring it once service recovers.

Pricing and availability

Do mid-conversation system instructions cost extra?

Mid-conversation system instructions carry no separate fee. Tokens in system_input steps are billed at the standard input token rate for the model being called, and earlier turns remain eligible for cached-token rates when rules or tools change.

The feature is in public preview across all Gemini 4 models in the Interactions API through the v1beta endpoint. Google said support for Gemini Enterprise Agent Platform is coming soon. Developers can read the documentation, compare Gemini 4 models to find the best fit for their workload, or join the discussion on the AI Developer Forum.

Este artigo foi escrito com a assistência de IA.
News Factory APP - notícias agênticas para impulsionar seu SEO e AEO.