Developers can now update system instructions or tools in the middle of a conversation while keeping the prompt cache intact.
Your browser does not support the audio element.
Today, mid-conversation system instruction and tool changes are available in preview in the Gemini API through the Interactions 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 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.
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:
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.
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:
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 .
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 across all Gemini 4 models in the Interactions API (through v1beta endpoint ), in the Gemini API . Support for Gemini Enterprise Agent Platform to come soon.
Get started today by reading the documentation , comparing Gemini models to find the right Gemini 4 model for your workload, and join the discussion on the AI Developer Forum .




Loading comments…