Skip to content
Theme
OnDevice Tools

AIAI Tools & Apps

Gemini API adds mid-conversation instructions for tools

Google AI Blog reports a public preview of mid-conversation instructions in the Gemini API. The update lets developers change system instructions or tools during a session while preserving prompt cache reuse.

Illustration of a Gemini API interface showing mid-conversation instructions and tool updates

Key takeaways

  • The Gemini API now offers mid-conversation instructions in a public preview.
  • The update allows system instruction and tool changes during a session while earlier turns stay cached.
  • Tool updates use added_tools and removed_tools, and only function tools are supported.
  • Mid-conversation system instructions have no separate fee, and earlier turns remain eligible for cached-token rates.
In this article
  1. What changed
  2. Important details
  3. Who is affected
  4. What it means

What changed

Before this update, a developer could not change a system instruction or update tools after the first turn without invalidating the prompt cache. That forced the system to process the entire conversation again, which raised latency and cost. The new preview path introduces a system_input step that can be placed at any turn boundary.

It gives the new step equal standing with the top-level system instruction and priority over user messages. Earlier turns stay cached, so the model does not need to recompute them when a later instruction or tool change arrives. This reduces the need to rebuild the prompt from scratch when only a later turn changes.

Important details

To add a new instruction, a developer sends a system_input step just before the next user_input step. The step links to the current exchange through the previous turn identifier. The top-level system_instruction should stay the same across turns so the prompt prefix remains valid for the cache.

Each system_input becomes its own step in the conversation history and remains active for the rest of the session. If a later system_input conflicts with an earlier one, the most recent instruction takes precedence. For tool changes, the top-level tools list should stay fixed, while added_tools and removed_tools alter the functions available to the model during the session. A system_input step can contain text content, tool updates, or both.

At present, only function tools can be changed through added_tools and removed_tools; MCP server tools are not supported. When one step has both removed_tools and added_tools, the API applies removals first, so a tool can be replaced in place. A brief text note next to a removal can help the model explain why the action is unavailable.

For tool updates, a developer can leave the top-level tools list as it is and use added_tools and removed_tools to alter the callable functions during the session. A support agent might start with get_store_hours and issue_refund. In a later turn, it could remove issue_refund and add create_escalation_ticket while leaving the top-level tools list the same.

The design can support rules that emerge during a conversation, including workspace rules, account entitlements and spending limits. It can also reinforce key formatting, tone or policy rules as a session grows. Patterns include granting write or account-action capabilities once authentication or plan approval is in place, taking them away when a read-only review is needed, and growing a tool set as the task requires.

Who is affected

This affects developers who build agents that span many turns. Long-running agents often work across dozens or even hundreds of turns, and their rules, permissions and tool options shift over time. The feature is intended for emerging rules, reinforcement of key formatting, tone or policy rules, dynamic permissions and mode switches, live operational changes, and growing tool sets.

It also matters for teams that need to audit multi-turn agent behaviour, because each system_input step can be listed in sequence with user_input and model_output. Applications must still authorise each function call before execution and keep untrusted external or end-user content away from system_input. Teams with large tool catalogs can start with a small set and add more as the task requires, without breaking the cache.

What it means

Illustration: AI, Gemini logo, code, crypto and the labels Gemini 4, Gemini API, Google

For developers, the next step is to read the documentation and compare Gemini models to select the right Gemini 4 model for the workload. The feature is offered in a public preview for every Gemini 4 model in the Interactions API through the v1beta endpoint, and also in the Gemini API. Support for Gemini Enterprise Agent Platform is planned to follow.

Instructions added mid-conversation do not have a separate charge, and tokens in system_input steps are charged using the model's standard input token rates. When rules or tools change, tokens from earlier turns still qualify for cached-token rates. Developers should also join the discussion on the AI Developer Forum.

The design separates orchestration controls from the model's core instructions. system_input, added_tools and removed_tools steer model behaviour, but the application must still authorise each function call before execution. The controls are not a replacement for backend authorisation.

Sources

  1. Introducing mid-conversation instructions in the Gemini APIGoogle AI Blog

Tags

Spotted a mistake? See our corrections policy. Read how News by OnDevice works in our editorial policy.