Gemini API New Feature: Dynamically Adjust Instructions and Tools Mid-Conversation

Gemini API adds mid-conversation instructions, enabling dynamic updates to system instructions and tools while preserving prompt cache.
The Gemini API launches mid-conversation instructions, allowing developers to update system instructions and tool lists during an ongoing conversation while preserving the prompt cache, avoiding session rebuilds due to configuration changes. Traditional APIs treat system instructions and tools as session-level static configuration, so mid-conversation adjustments require resetting the session, causing context loss and fragmented experiences. The new feature turns both into runtime-adjustable parameters, letting the model follow new roles, constraints, or tool definitions while leveraging existing cached context—balancing continuity, latency, and cost. This is especially valuable for multi-stage Agent applications requiring role switching and dynamic tool mounting, and it reduces session state management complexity. The article also notes that limitations such as instruction change frequency and the exact scope of cache preservation still require developer testing.
From "Set Once" to "Dynamic Tuning": Gemini API's Mid-Conversation Instructions
When building conversational AI applications, developers often face a dilemma: once system instructions are set, adjusting the role, constraints, or available tools mid-conversation typically requires restarting the conversation, leading to lost context and a fragmented experience. The Gemini API's newly launched mid-conversation instructions feature is designed precisely to solve this pain point.

According to the official announcement, this update allows developers to update system instructions and tools while a conversation is in progress, while preserving the prompt cache. This means the model doesn't need to reprocess already-cached context, thereby reducing latency and cost while maintaining continuity.
Why "Mid-Conversation Adjustment" Matters So Much
Traditionally, system instructions and tool definitions are fixed at the start of a session. If user needs change—for example, switching from general Q&A to a scenario requiring specific tools, or requiring the model to follow a new output format—developers can only reset the session or start a new round of conversation. This not only breaks conversational continuity but also makes previously accumulated context unusable.
The Gemini API's new capability turns system instructions and tools from "static configuration" into "dynamic parameters." Developers can adjust role settings, tool lists, or even behavioral constraints at any point in the conversation, while the model can still leverage existing cached context to continue reasoning.
System Instructions are a configuration layer in conversational AI interfaces that is independent of user messages, used to set global constraints such as the model's role, tone, safety boundaries, and output format. In mainstream APIs like Gemini and OpenAI, system instructions are typically passed as a top-level field of the request, handled separately from the conversation history. The model prioritizes system instructions when generating each response, with higher priority than similar requirements in user messages. Therefore, changes to system instructions directly affect the model's behavioral tendencies, and traditional APIs treat them as a static property of the session—changing them means a new session.
Function Calling is the ability for large models to declare during a conversation that external tools need to be invoked: the model doesn't execute functions directly but outputs a structured call request (function name and parameters), which the developer executes and returns the result to the model for continued reasoning. Tool definitions (name, description, parameter schema) are also typically passed with the request, so adding or removing tools is likewise a session-level configuration. Gemini's mid-conversation instructions feature turns this configuration layer into a mutable parameter, enabling dynamic tool mounting and synchronized updates to system instructions within the same session.
Preserving Prompt Cache: Dual Benefits for Performance and Cost
The official announcement specifically emphasizes "preserving your prompt cache." In long conversations or high-frequency call scenarios, prompt caching can significantly reduce redundant computation. If the cache were cleared every time instructions are adjusted, both response speed and call costs would be affected. The new feature preserves the cache when instructions change, so dynamic adjustment no longer comes at the expense of performance.
This is particularly valuable for Agent-type applications that require multi-stage tasks, role switching, or dynamic tool mounting. For example, a customer service bot can first converse as a general assistant, then dynamically load order query tools after identifying user intent, and simultaneously update system instructions to constrain the tool call format—all without interrupting the session.
Prompt Caching is an optimization mechanism for reducing large model inference costs and latency: for prefix content that appears repeatedly in requests (such as long system instructions, tool definitions, fixed documents, or earlier conversation turns), the server caches the computed intermediate state (KV cache), and subsequent requests that hit the cache only need to compute the new portion. Since Transformer attention computation scales approximately quadratically with input length, caching can significantly reduce time-to-first-token (TTFT) and billed token counts. Caching is typically conditioned on "prefix matching"—once the prefix content changes, the cache after it is invalidated. This is exactly why mid-conversation instructions specifically emphasize "preserving the cache": if instruction updates cause the prefix to be rewritten, the caching benefit drops to zero. Gemini's implementation ensures that system instruction and tool changes don't break existing caches, thereby maintaining performance advantages during dynamic adjustments.
Practical Impact on Developers
From an engineering perspective, mid-conversation instructions reduce the complexity of state management. Developers no longer need to design extra session reconstruction logic for "instruction changes," nor worry about performance jitter caused by cache invalidation. Combined with the Gemini API's existing function calling capabilities, dynamic tool management makes Agent workflows more flexible.
It's worth noting that this release focuses on capability introduction; specific best practices and limitations (such as instruction change frequency and the exact scope of cache preservation) still need to be verified by developers in actual integration. It's recommended to thoroughly test model behavior consistency after instruction switches when critical business logic is involved.
Summary
The Gemini API's mid-conversation instructions feature elevates system instructions and tools from session-level configuration to runtime-adjustable parameters, while preserving prompt caching—a key performance factor. For developers building complex conversational applications and Agents, this offers a lighter-weight, more coherent approach to context management that's worth trying in the next iteration.
Background
Agent refers to a system that uses a large model as its reasoning core and can autonomously plan steps and invoke external tools to complete multi-stage tasks. Unlike single-turn Q&A, an Agent's workflow typically includes intent recognition, task decomposition, tool selection, and result integration, with each stage having different requirements for model role, available tools, and output format. Traditional implementations often maintain separate sessions or prompt templates for each stage, resulting in high state-switching costs. Mid-conversation instructions allow Agents to adjust configuration by stage within the same session—for example, first decomposing tasks as a planner, then mounting specific tools as an executor—while reusing cached context. This provides a cleaner engineering path for building low-latency, context-coherent multi-stage Agents.
Related articles

Pharmacology Knowledge Challenge: Key Points on Antibacterial, Endocrine, and Immune Drugs
The second Pharmacology Knowledge Challenge covers high-yield topics in antibacterial, endocrine, respiratory/GI, and immuno-oncology pharmacology, including aminopenicillins, aminoglycoside synergy, adefovir dosing, glitazones, long-term glucocorticoid side effects, switching hyperthyroidism drugs in pregnancy, natalizumab risks, calcineurin inhibitors, and NSAID selection.

How to Avoid an AI War with China: Kokotajlo's Plan A and Verification-Based Transparency
AI researcher Daniel Kokotajlo proposes Plan A in his conversation with Lex Fridman: through data center mutual inspections and real-time public disclosure of training activity, the US and China can synchronize a slowdown of the AI race without trusting each other, preventing an out-of-control superintelligence race from escalating into conflict.

Framework Laptop 12 Review: Modular Design Shines Brighter with Linux
Framework Laptop 12 review: modular ports and easy repair still impress, but the device has flaws. Switching to Linux makes it more fun, while Windows 11's service pushing detracts. We analyze who it suits and the trade-offs of modular design.