Google Updates Gemini Interactions API to Enable Dynamic Instruction Changes Mid-Session Without Breaking Prompt Cache
1 hour ago / Read about 0 minute
Author:小编   

Google has introduced a preview feature in its Gemini Interactions API that lets developers modify system instructions and tool lists mid-session. With this capability, developers can append system instructions or adjust callable tools at any turn during agent execution—without having to reprocess the full prior conversation history and without incurring additional costs for historical context processing. Previously, developers had two ways to adjust an agent's behavior rules: sending new instructions as a user message, which suffered from insufficient priority and could be easily mimicked or interfered with by users; or rewriting the system instructions and replacing the tool list, which would invalidate the prompt cache and drive up both cost and latency. This update adds a system_input field that, when combined with the previous turn's interaction ID, allows system instructions to be appended without interrupting the session. Google recommends keeping the top-level system_instruction unchanged to preserve the cache; when old and new instructions conflict, the latest instruction takes precedence. Developers can also retrieve the complete interaction record in execution order via client.interactions.get. Tool adjustments are handled through the added_tools and removed_tools fields, with removals applied before additions. Currently, only dynamic updates to function tools are supported; MCP server tools are not yet supported.

  • C114 Communication Network
  • Communication Home