Gemini API keeps cache intact when instructions and tools change mid-conversation
In brief
Google has released in preview a feature that preserves the prompt cache in the Gemini API's Interactions API even when system instructions and tools are changed partway through a conversation.
2 min read
Translated from the Korean original. Read the original in Korean
Why it matters
- It eases the burden on long-running agents, which had to reprocess the entire conversation, with the cost and delay that entails, whenever rules or permissions changed.
Key details
Developers send new instructions or tool changes by inserting a system_input step directly before user_input on each turn. This step carries the same authority as the top-level system instruction and takes precedence over user messages, and earlier turns stay in the cache. For tools, the top-level list is kept the same on every turn, and added_tools and removed_tools change which functions can be called. If both fields are in a single step, removals are processed first, so a definition can be replaced in place.
Context
Until now, developers either put new instructions in a user message or rewrote the system instructions and tools. The former carries a different weight from top-level instructions, so users could imitate it, and the latter invalidated the cache. Each system_input persists until the session ends, and if they conflict, the model follows the most recent instruction. There is no separate charge, and system_input tokens are billed at the standard input token rate for the model in question. Turns before a change may be charged at the cached token rate.
Outlook
The public preview is available through the v1beta endpoint on all Gemini 4 models in the Interactions API. Tool updates support function tools only, and MCP server tools are not covered. Google said this step is a control for adjusting model behavior, and advised that applications approve function calls themselves on the backend and not include unverified external or end-user content.
What's next
- Support for the Gemini Enterprise Agent Platform will be added soon.