Updating system instructions and tools mid-conversation in the Gemini API

Developers can now update system instructions and tools in the middle of a live conversation without invalidating the prompt cache.

3 min read

Diagram showing cached conversation turns followed by a dynamic system input step that modifies tools.
Conceptual overview of updating system instructions and tools mid-conversation without breaking the prompt cache.

Developers building long-running AI applications often face a frustrating limitation. As sessions grow to span dozens or hundreds of turns, rules, permissions, and available tools inevitably change. Until now, giving a model a new system instruction or updating tools required rewriting the configuration, which invalidated the prompt cache. When the cache breaks, the model must reprocess the entire conversation history from scratch, driving up both financial costs and response latency.

To solve this challenge, the Gemini API now supports mid-conversation system instruction and tool changes through the Interactions API. This feature allows autonomous agents to adapt to new rules mid-session without re-reading the entire conversation history or triggering expensive cache reloads.

Key facts

API Endpoint
v1beta
API interface showing cached turns 1-12 and a new system input removing create_release and adding get_logs.
Detailed view of the Interactions API handling a system_input step at turn 13 with added and removed tools., Source ↗

How the Interactions API handles mid-conversation updates

The Interactions API introduces a new step type called system_input. Developers can send a system_input step at any turn directly before the user input. This step carries the exact same authority as top-level system instructions and takes precedence over regular user messages, while all earlier turns stay fully cached.

Because the system_input step appends at the current turn boundary, all preceding tokens remain identical from turn to turn, allowing the system to reuse the prompt cache. When a newer instruction conflicts with an earlier one, the model automatically favors the most recent instruction. Developers can inspect these steps when retrieving interactions, making multi-turn agent traces much easier to audit and debug.

Updating tools without breaking the cache

Tool declarations normally sit at the start of the prompt, meaning any changes to the top-level tool list between turns will break the prompt cache. To prevent this, developers should keep the top-level tools list identical on every turn and instead use specialized parameters to update functions as the session evolves.

The API provides specific controls for this workflow:

  • added_tools: introduces new functions the model can call.
  • removed_tools: strips away access to specific functions.

When a single step includes both fields, the API processes removed tools before added tools, allowing developers to replace a tool definition cleanly in place. It is important to note that only function tools are currently supported for these dynamic updates, while Model Context Protocol server tools are not.

Practical use cases for dynamic instructions

This capability opens up several architectural patterns for developers building interactive AI systems. Session-dependent constraints allow applications to apply rules discovered partway through a conversation, such as workspace settings or account spending limits. Long-horizon instruction reinforcement helps re-emphasize key formatting or policy rules deep into multi-turn sessions as context grows.

Furthermore, developers can implement dynamic permissions by enabling write actions only after authentication or plan approval, and removing them when returning to read-only review. Live operational changes also become feasible, allowing systems to disable a tool and update guidance mid-session when a downstream dependency goes offline. Finally, applications with large tool catalogs can start with a small set of tools and add more as the task requires, avoiding the need to declare every tool up front.

Availability and pricing

Mid-conversation system instructions carry no separate fee. Tokens included in system_input steps are simply billed at standard input token rates for the model being called, and earlier turns remain eligible for cached-token rates. This feature is available in public preview across all Gemini 4 models in the Interactions API through the v1beta endpoint.

Source: Original announcement

Worth a read?

Report

Comments