Developers can now update system instructions or tools in the middle of a conversation while keeping the prompt cache intact.
Developers can now update system instructions or tools in the middle of a conversation while keeping the prompt cache intact. Today, mid-conversation system instruction and tool changes are available in preview in theGemini APIthrough theInteractions API. This lets agents adapt to new rules and tools mid-session without re-reading the entire conversation or driving up costs. Long-running agents often work across dozens, if not hundreds, of turns. Along the way, rules, permissions and available tools change. Until now, you couldn't give the model a new system instruction or update tools without invalidating the cache. Developers have commonly relied on two workarounds: The Interactions API now allows you to send asystem_inputstep at any turn with system instruction or tool changes. It carries the same authority as your top-level system instruction and takes precedence over user messages, while earlier turns stay cached. To send an instruction mid-conversation, pass the previous turn's ID inprevious_interaction_idand place asystem_inputstep directly beforeuser_inputin the input array. Keep your top-levelsystem_instructionunchanged across turns so the prompt prefix stays valid in the cache: Eachsystem_inputappends to the conversation history as its own step and stays active for the rest of the session alongside the top-levelsystem_instruction. Rules that cover different topics remain in effect together. When a newersystem_inputconflicts with an earlier instruction, the model favors the most recent instruction. When you retrieve an interaction withclient.interactions.get(id=turn2.id), eachsystem_inputstep appears in order alongsideuser_inputandmodel_output, making multi-turn agent traces straightforward to audit and debug: Becausesystem_inputappends at the current turn boundary, all preceding tokens remain identical from turn to turn and reuse the prompt cache. You can send onesystem_inputstep per turn directly beforeuser_input, containing text content, tool updates, or both. Tool declarations sit at the start of the prompt, so changing the top-level tools list between turns breaks the prompt cache. Withsystem_input, we recommend you leave the same top-level tools list on every turn and useadded_toolsandremoved_toolsto update which functions the model can call as the session evolves. Only updating function tools viaadded_toolsandremoved_toolsis currently supported and not MCP server tools. In this example, a support agent starts withget_store_hoursandissue_refund. On the next turn, the app removesissue_refundand addscreate_escalation_ticketwhile keeping the top-leveltoolslist identical: Tool updates stay in effect until a latersystem_inputchanges them. When a single step includes both fields, the API processesremoved_toolsbeforeadded_tools, letting you replace a tool definition in place. Adding a short text note when removing a tool also gives the model context to explain why an action is unavailable. Keep in mind thatsystem_input,added_tools, andremoved_toolssteer model behavior and serve as orchestration controls. Your application should still authorize every function call on the backend before executing it and keep untrusted external or end-user content out ofsystem_input. Session-dependent constraints:Apply rules discovered partway through a conversation, such as workspace settings, account entitlements, or spending limits. Long-horizon instruction reinforcement:Re-emphasize key formatting, tone, or policy rules deep into multi-turn sessions as context grows. Dynamic permissions and mode switches:Enable write or account-action tools after authentication or plan approval, and remove them when returning to read-only review. Live operational changes:Disable a tool and update guidance mid-session when a downstream dependency goes offline, then restore it once service recovers. Large tool catalogs: Start with a small set of tools and add more as the task needs them, without declaring every tool up front or breaking the cache. Mid-conversation system instructions carry no separate fee. Tokens in system_input steps are billed at the standard input token rates for the model you call. Earlier turns remain eligible for cached-token rates when rules or tools change. Mid-conversation system instructions are available in public preview acrossall Gemini 4 modelsin the Interactions API (throughv1beta endpoint), in theGemini API. Support forGemini Enterprise Agent Platformto come soon. Get started today by reading thedocumentation,comparing Gemini modelsto find the right Gemini 4 model for your workload, andjoin the discussion on the AI Developer Forum.
