Gemini API adds mid-conversation system instructions
Google's Gemini API now lets developers change system instructions and tools partway through a session without invalidating the prompt cache, which removes a cost and latency penalty for long-running agents.
Google announced that system instruction and tool changes can now be made mid-conversation in the Gemini API. The feature is in preview and works through the Interactions API. Google AI Studio said the public preview covers all Gemini 4 models and is available through the v1beta endpoint.
Until now, developers had two workarounds, and both had drawbacks. They could send new rules as a user message, which keeps the cache intact. But those messages don't carry the weight of a real system instruction, and users can try to imitate them. They could also rewrite the system instruction or the tools list. That invalidates the prompt cache, so the model has to reprocess the whole conversation history, which adds cost and latency.
The new approach is a system_input step that goes directly before user_input in a turn, with the previous turn passed in previous_interaction_id. Google says this step has the same authority as the top-level system instruction and takes precedence over user messages. Because it is added at the current turn boundary, all earlier tokens stay the same and can still be served from the cache. Each system_input stays in effect for the rest of the session. When a newer instruction conflicts with an older one, the model favours the most recent.
Tools are updated the same way. Developers keep the same top-level tools list on every turn and use added_tools and removed_tools inside system_input. In Google's example, a support agent loses issue_refund when an account goes under billing review. Only function tools are supported for now, not MCP server tools.
Each turn can carry one system_input. These steps show up in order when an interaction is retrieved, so agent traces can be audited. Google's code samples use a model called gemini-4-neon, but the feature isn't limited to that model. The post doesn't give pricing details or a date for general availability.
Sources
Updates
- Added that the preview covers all Gemini 4 models via the v1beta endpoint