ZICQ
中 Log in / Sign up
Newsroom Official LLMs & Foundation Models #Gemini API #System Instructions #Tool Calling #Prompt Caching

Gemini API Adds Mid-Conversation System and Tool Updates with Prompt Cache Preservation

Avatar of Mr.Xu

By Mr.Xu Compiled & Reviewed by Editorial

Published:

中文阅读 (Chinese) English Version
Co-reading Select any sentence in the article to highlight, annotate, or copy a quote card. Join discussion ↓

Summary:Google has added mid-conversation updates to the Gemini API, allowing developers to change system instructions and tool configurations during an active exchange while preserving the existing prompt cache. The capability targets long-running agents whose policies, routing rules, permissions, or available tools can evolve without restarting the session, potentially reducing repeated input tokens, cost, and time-to-first-token latency. The announcement does not specify supported models, SDK syntax


What Changed

Google has added the ability to update system instructions and tool configurations during a Gemini API conversation. Developers can adjust behavioral constraints or the available tool set while continuing the same exchange, and the central promise is that the existing prompt cache can be preserved during the update.

This addresses a common problem in long-running agents: backend policies change, tool permissions are tightened, or a business integration becomes temporarily unavailable. The traditional workaround is to create a new session and replay a long history. Updating controls in place can reduce repeated context, input cost, and time-to-first-token latency.

The available announcement confirms only this capability. It does not list supported models, SDK methods, regions, or rate limits, nor does it say whether an update can occur while a streamed response is still active. Unless the formal API documentation states otherwise, mid-conversation should be interpreted as a turn-boundary capability.

Why Cache Preservation Matters

A simplified request can be represented as C_t = Tokenize(S || T || H_t || u_t), where S is the system instruction, T is the tool declaration set, H_t is the conversation history, and u_t is the current user input. Tool names, descriptions, and JSON Schemas are generally serialized into the model context as well.

When the configuration changes from S and T to S' and T', a naive request becomes C'_t = Tokenize(S' || T' || H_t || u_t). In common exact-prefix caching systems, the cache key is tied to the model version, configuration, and token prefix. A change near the beginning can therefore invalidate the entire downstream prefix. To update configuration while retaining the cache, the service must logically separate the stable conversation prefix from mutable controls, remap cache segments, or use an equivalent mechanism. Google has not disclosed the implementation, and the externally visible result is insufficient to infer the internal cache layout.

Evaluation should distinguish three layers of semantics: whether historical messages still hit the cache, whether the updated instruction enters the effective context, and whether the model can still observe the old instruction alongside the new one. The preservation claim primarily indicates that the historical prefix does not need to be rebuilt. Whether the update itself is cached, which models qualify, and when entries expire still require inspection of usage metadata and behavioral tests.

Tool Updates Are More Than List Changes

Tool declarations are both part of the prompt and an executable contract between the model and the application.

  • Adding a tool expands the model's action space, but more names, similar descriptions, and larger Schemas can increase selection ambiguity and input overhead.
  • Removing a tool does not erase historical function calls. The execution layer must reauthorize every call against the current allowlist instead of assuming the model will stop selecting the old tool.
  • Changing a parameter Schema can break historical-call compatibility. Explicit versions such as search_v2, together with migration and idempotency policies, are safer than silently redefining the same tool.
  • Updating a system instruction needs a clearly defined effective turn. A policy revision number is preferable to overwriting a string, particularly when configuration updates and message appends can race.

System instructions constrain model behavior; they are not an authorization boundary. The tool gateway should still validate caller identity, argument ranges, permissions, rate limits, and the active policy revision.

Engineering Trade-offs

The primary benefit is avoiding reconstruction and replay of a long session. For agents with extensive context and frequent tool use, prompt-cache preservation may reduce repeated input tokens, request cost, and prefill latency. Dynamic configuration also changes a conversation from a fixed script into an evolving runtime state.

The cost is state consistency. Cached content may carry an old policy or tool definition, and seeing old and new constraints together can cause behavioral drift. Frequent tool changes also make call chains less deterministic. Applications should treat model-visible configuration as versioned state rather than an ephemeral string. Concurrent scenarios require serialization of configuration revisions and message appends, or a revision mechanism that resolves out-of-order updates.

The feature also introduces stronger platform coupling. Other model APIs may require separate implementations for dynamic system instructions, tool-Schema validation, and cache lifecycle management, so equivalent behavior should not be assumed.

Performance and Quality Evaluation

The official summary provides no benchmarks, making it impossible to directly quantify cache-hit rates, time-to-first-token latency, or tool-calling accuracy. Evaluation should use at least three controls: a fixed-configuration conversation, a restarted conversation for the same task, and an in-place configuration update.

Under the same model, region, quotas, and traffic distribution, teams should measure:

  • Cached-token share and changes in cache hits before and after an update;
  • P50, P95, and P99 TTFT;
  • Input cost per request and aggregate throughput;
  • Instruction-adherence rate, tool-selection accuracy, and argument-validity rate;
  • Stale-tool invocation and Schema-mismatch rates;
  • Consistency of historical facts, tool state, and policy across consecutive updates.

The test matrix should cover instruction-only changes, tool addition, tool removal, Schema modification, updates immediately after a function call, and concurrent revisions rather than validating only the ideal sequential path.

Deployment Guidance

  1. Version system instructions and tool Schemas. Record every change as an auditable policy revision instead of overwriting configuration in place.
  2. Separate stable persona from dynamic policy. Keep long-term identity, formatting, and safety constraints in a stable prefix; apply runtime changes through controlled revisions to reduce cache invalidation and semantic conflicts.
  3. Enforce authorization at the tool layer. Validate tool versions, parameter Schemas, caller identity, and current permissions rather than treating model prompts as a security boundary.
  4. Handle historical-call compatibility. Define explicit rejection, migration, or compatibility policies for older function calls, and use idempotency keys to prevent duplicate side effects during retries.
  5. Log effective configuration and cache metrics. Include instruction revision numbers, tool-Schema hashes, cached-token counts, TTFT, and tool-rejection reasons.
  6. Match update frequency to the workload. Avoid rewriting the tool set every turn; aggregate short-lived changes into stable windows to improve cache reuse and backend optimization.
  7. Roll out gradually with a fallback. Verify supported models, SDKs, regions, and quotas before exposing the feature to production long-running agents.

Source: Google AI Blog (2026-12-03)

— END —

Tags: #Gemini API #System Instructions #Tool Calling #Prompt Caching

Editorial & Fact-Checking Note: This article is compiled from primary research, official release documentation, and source papers by the ZICQ Newsroom pipeline with automated entity verification and human editorial review. If you notice any technical inaccuracy, please submit a correction via our corrections policy or email our editorial desk directly.

What's your take on this story?
Explore & Submit Works

Community Comments

Loading live comments and annotations…