ProductsOfficial

Gemini API 支持对话中途更新系统指令且保留提示词缓存

Introducing mid-conversation instructions in the Gemini API

Why we picked it

做客服机器人或多轮智能体的开发者可以看看这个。Gemini API 现在能在对话跑到一半时改系统指令和换工具,缓存还不失效。对比 OpenAI 那边改策略得重开会话,长对话场景能省不少 token 钱。

Google 在 Gemini API 中推出 mid-conversation instructions 功能,开发者可以在一次对话进行中途更新 system instructions 和工具配置,而不必重开会话。该功能的关键设计是同步保留 prompt cache,用户此前缓存的提示词不会被中途修改作废,避免重新计算带来的延迟和成本。

Body

此前 Gemini API 要求 system instructions 在会话开始时确定,若要变更指令或挂载新工具,只能结束当前会话再重新发起,缓存也随之失效。新功能允许在保持同一会话上下文的前提下动态调整行为,适用于客服场景中按用户意图切换话术规则、或在长对话里中途启用搜索、代码执行等工具。

对构建多轮智能体的开发者来说,这意味着可以在不牺牲缓存经济性的前提下实现更灵活的运行时控制。相比 OpenAI Responses API 需要为策略变更新开会话的做法,Gemini 的这一机制在长会话、高轮次应用中能明显降低 token 开销。

Original · Google Blog: AI

Introducing mid-conversation instructions in the Gemini API

Update system instructions and tools mid-conversation while preserving your prompt cache.

Industry Coordinates & Source Verification

This report is categorized under AITOP's "Products" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include Gemini API, prompt cache, Google, agents.

Primary source verification: published directly by Google Blog: AI with first-party authority. Cross-source corroboration: 11 independent sources have covered this development (including Philipp Schmid, techcrunch, Logan Kilpatrick), confirming industry-wide signal strength.

Spotted an error in the summary or translation? Tell us