NewsCrawler.org

Gemini API adds mid-conversation instructions and tool updates in preview

Gemini API adds mid-conversation instructions and tool updates in preview
Preview of inline option 2 for min-conversation updates. Adding instructions and tools without resetting cache
Image: Reddit

Mid-conversation system instruction and tool changes are now available in preview in the Gemini API through the Interactions API. This lets agents adapt to new rules and tools during a session without re-reading the whole conversation or driving up costs. Before this, developers either put new instructions in a user message, which carries less weight and can be imitated by users, or rewrote the system instruction or tools, which invalidated the prompt cache[1] and made the model reprocess the entire history.

The new system_input step can be sent at any turn. It has the same authority as the top-level system instruction, takes precedence over user messages, and earlier turns stay cached. To use it, pass the previous turn's ID in previous_interaction_id, keep the top-level system_instruction unchanged, and place a system_input step directly before user_input. Each system_input stays active for the rest of the session, and when a newer one conflicts with an earlier one, the model favors the newer instruction.

For tools, the top-level tools list should stay the same on every turn. Instead, added_tools and removed_tools update which function tools the model can call, and MCP server[2] tools are not currently supported. Mid-conversation instructions carry no separate fee. The article recommends that applications still authorize every function call on the backend before executing it.

Product Gemini API ai.google.dev

Google's API for building apps and agents with Gemini models, including the Interactions API used for conversations and tool calls.

Read the original blog.googleDiscussion

Sources

Published: First seen: Читать по-русски

Open as a page