Google Gemini API Adds Mid-Conversation System Instructions to Preserve Prompt Cache
Developers can now update system rules and tools during a session without invalidating the cache, reducing costs for long-running agents.
Google has introduced mid-conversation system instructions and tool updates in the Gemini API through its new Interactions API. This feature allows developers to change agent behavior or available functions partway through a conversation while keeping the prompt cache intact.
Previously, updating top-level system instructions or modifying the list of tools would invalidate the cached prefix, forcing the model to reprocess the entire conversation history. This significantly increased latency and cost for long-running agents. The new system_input step carries the same authority as initial instructions but is appended at the current turn boundary, ensuring that all preceding tokens remain identical and reusable from the cache.
The update also supports dynamic tool management via added_tools and removed_tools fields within the system_input step. Developers can keep the top-level tool definitions static to preserve the cache while restricting or expanding the model's callable functions on a per-turn basis. Currently, this mechanism supports function tools but not MCP server tools.
This capability is available in public preview across all Gemini 4 models using the v1beta endpoint. It addresses a key pain point for building stateful AI agents by allowing real-time adaptation to changing constraints—such as deployment freezes or billing reviews—without the performance penalty of full context reprocessing.