Gemini API lets agents change rules mid-chat and keep cache

In short

What problem does mid-conversation system instruction solve?

An AI model does not remember a chat the way a person does. On every turn, the application sends the whole conversation so far. To avoid paying to process the same text again and again, the provider keeps a prompt cache: if the start of the new prompt is identical to the last one, the already-processed part is reused at a lower rate.

That works only while the beginning stays the same. The system instruction and the list of tools sit at the very start of the prompt, so editing either one changes the beginning and throws the cache away.

Google's post says long-running agents often work across "dozens, if not hundreds" of turns, and that rules, permissions and tools change along the way. Developers had two workarounds, it says:

How does the system_input step work?

The Interactions API now accepts a system_input step at any turn. Per the post, it carries the same authority as the top-level system instruction and takes precedence over user messages, while earlier turns stay cached.

To use it, the developer passes the previous turn's ID in previous_interaction_id and puts the system_input step directly before the user_input step. The top-level system_instruction stays unchanged on every turn, so the start of the prompt is the same and the cache stays valid.

Google's example is an infrastructure troubleshooting assistant. After a first question about a latency spike, the app sends a system_input saying a production deployment freeze is active, recommending read-only diagnostics and no further rollouts. When the user then asks for the command to deploy a new release, the sample reply says a freeze is active and offers checks instead.

Other behaviour the post describes:

Can tools change mid-conversation too?

Yes, with a limit. Tool declarations also sit at the start of the prompt, so changing the top-level tools list breaks the cache. Google recommends leaving that list identical on every turn and adding added_tools and removed_tools to a system_input step.

Its example is a support agent that starts with get_store_hours and issue_refund. When an account goes under billing review, the app removes issue_refund and adds create_escalation_ticket, with a note telling the agent to explain that refunds are paused and offer to escalate. If a step has both fields, removals are processed before additions, so a tool definition can be replaced in place. Changes last until a later system_input changes them.

Only function tools can be updated this way for now, not MCP server tools (tools an agent reaches through the Model Context Protocol), the post says.

Google says these steps steer the model; they are not a security lock. Applications should still authorise every function call on their own backend and keep untrusted external or end-user content out of system_input.

What does it cost, and where is it available?

The post says mid-conversation system instructions carry no separate fee. Tokens in system_input steps are billed at the standard input rate of the model called, and earlier turns stay eligible for cached-token rates when rules or tools change. It gives no price figures, and no measured savings.

It is available in public preview across all Gemini 4 models in the Interactions API, through the v1beta endpoint of the Gemini API. Support for Gemini Enterprise Agent Platform is "to come soon".

Google lists these uses:

What is not stated

This is a company announcement, and we have not run the API. The post does not say how much cost or delay is saved, how reliably the model follows a mid-conversation rule over a user message, or whether other providers offer the same. Treat the "same authority" and "stays cached" statements as Google's claims until developers test them.

Terms in plain English

Sources

Sources

Related stories

More from Teach the Bot

All stories from Teach the Bot