Introducing mid-conversation instructions in the Gemini API Google made mid-conversation system instruction and tool changes available in preview in the Gemini API through the Interactions API, letting agents adopt new rules and tools mid-session without invalidating the prompt cache. Developers send a `system_input` step before `user_input` with the prior turn's `previous_interaction_id`, and the new instruction carries the same authority as the top-level system instruction while earlier turns stay cached; conflicting instructions resolve in favor of the most recent one. The change removes the two prior workarounds — sending instructions as a user message, which lacks system-level authority, or rewriting the system instruction, which forces the model to reprocess the entire conversation history and adds cost and latency. Introducing mid-conversation instructions in the Gemini API Today, mid-conversation system instruction and tool changes are available in preview in the Gemini API https://aistudio.google.com/docs/mid-conversation-instructions through the Interactions API https://aistudio.google.com/docs/interactions-overview . 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: - Putting instructions in a user message: To preserve the cache, you could send new system instructions as a user message. These don’t carry the same weight as your top-level system instructions and allow users to try and imitate them. - Rewriting system instruction or tools: Rewriting the system instruction or changing tools invalidates the prompt cache. The model reprocesses the entire conversation history, adding cost and latency. The Interactions API now allows you to send a system input step 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. How it works To send an instruction mid-conversation, pass the previous turn's ID in previous interaction id and place a system input step directly before user input in the input array. Keep your top-level system instruction unchanged across turns so the prompt prefix stays valid in the cache: python from google import genai client = genai.Client http options={"api version": "v1beta"} system instruction = "You are an infrastructure troubleshooting assistant." turn1 = client.interactions.create model="gemini-4-neon", system instruction=system instruction, input="Latency just spiked on our service. What should I check first?", turn2 = client.interactions.create model="gemini-4-neon", previous interaction id=turn1.id, system instruction=system instruction, input= { "type": "system input", "content": { "type": "text", "text": "A production deployment freeze is now active. " "Recommend read-only diagnostics and do not allow further rollouts." , } , }, { "type": "user input", "content": { "type": "text", "text": "Give me the command to deploy a new release.", } , }, , print turn2.output text Each system input appends to the conversation history as its own step and stays active for the rest of the session alongside the top-level system instruction . Rules that cover different topics remain in effect together. When a newer system input conflicts with an earlier instruction, the model favors the most recent instruction. When you retrieve an interaction with client.interactions.get id=turn2.id , each system input step appears in order alongside user input and model output , making multi-turn agent traces straightforward to audit and debug: { "steps": { "type": "system input", "content": { "type": "text", "text": "A production deployment freeze is now active. Recommend read-only diagnostics and do not allow further rollouts." } }, { "type": "user input", "content": { "type": "text", "text": "Give me the command to deploy a new release." } }, { "type": "model output", "content": { "type": "text", "text": "A production deployment freeze is active, so we can't release. Here are some checks you can run..." } } } Because system input appends at the current turn boundary, all preceding tokens remain identical from turn to turn and reuse the prompt cache. You can send one system input step per turn directly before user input , containing text content, tool updates, or both. How mid-conversation tool updates work Tool declarations sit at the start of the prompt, so changing the top-level tools list between turns breaks the prompt cache. With system input , we recommend you leave the same top-level tools list on every turn and use added tools and removed tools to update which functions the model can call as the session evolves. Only updating function tools via added tools and removed tools is currently supported and not MCP server tools. In this example, a support agent starts with get store hours and issue refund . On the next turn, the app removes issue refund and adds create escalation ticket while keeping the top-level tools list identical: python from google import genai client = genai.Client http options={"api version": "v1beta"} tools = { "type": "function", "name": "get store hours", "description": "Look up opening hours for a store.", "parameters": { "type": "object", "properties": {"store id": {"type": "string"}}, "required": "store id" , }, }, { "type": "function", "name": "issue refund", "description": "Refund an order.", "parameters": { "type": "object", "properties": {"order id": {"type": "string"}}, "required": "order id" , }, }, turn1 = client.interactions.create model="gemini-4-neon", input="Hi, I have a question about my order.", tools=tools, turn2 = client.interactions.create model="gemini-4-neon", previous interaction id=turn1.id, tools=tools, input= { "type": "system input", "content": { "type": "text", "text": "This account is under billing review. Explain " "that refunds are paused and offer to escalate." , } , "removed tools": {"type": "function", "name": "issue refund"} , "added tools": { "type": "function", "name": "create escalation ticket", "description": "Escalate a billing review issue to support.", "parameters": { "type": "object", "properties": {"order id": {"type": "string"}}, "required": "order id" , }, } , }, { "type": "user input", "content": {"type": "text", "text": "Refund order 12345."} , }, , print turn2.output text Tool updates stay in effect until a later system input changes them. When a single step includes both fields, the API processes removed tools before added 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 that system input , added tools , and removed tools steer 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 of system input . How you can use it 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. How pricing and supported models work 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 across all Gemini 4 models https://aistudio.google.com/docs/latest-model in the Interactions API through v1beta endpoint https://aistudio.google.com/api-reference/api-versions , in the Gemini API https://aistudio.google.com/docs/mid-conversation-instructions . Support for Gemini Enterprise Agent Platform https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/interactions to come soon. Get started today by reading the documentation https://aistudio.google.com/docs/mid-conversation-instructions , comparing Gemini models https://aistudio.google.com/docs/choosing-a-model to find the right Gemini 4 model for your workload, and join the discussion on the AI Developer Forum https://discuss.ai.google.dev/ .