Google Adds Mid-Conversation Instructions to the Gemini API
Google's Gemini API now lets developers change system instructions and tools mid-conversation through a system_input step in the Interactions API. Earlier turns stay in the prompt cache at cheaper rates, with no extra fee for the feature.
Say you have been debugging one bug for an hour in a single chat with Gemini. The model knows your code, your error logs, and every fix you have already tried. Now you want shorter answers in simple English.
Google's Gemini API now lets you change system instructions and tools in the middle of a conversation. You send a system_input step through the Interactions API, and earlier turns stay in the prompt cache. Those turns are billed at cheaper cached-token rates. It is in public preview on all Gemini 4 models.
What Google launched in the Gemini API
Google added mid-conversation system instructions and tool changes to the Gemini API as a public preview in the Interactions API (v1beta), announced on Google's own developer blog.
The preview runs on every model in the Gemini 4 family through the Interactions API. Google's own examples use gemini-4-neon. If you have not tried that model yet, my post on projects you can build with Gemini 4 Neon is a good place to start.
Gemini's older endpoints are not part of this feature. You need the Interactions API, because the feature depends on the API remembering earlier turns for you.
How a system_input step works
A step is one item in the input list you send. A system_input step goes before user_input on any turn and points to the earlier turn with previous_interaction_id, so the model reads it as part of the same thread.
Google gives this step the same authority as the top-level system instruction. It also takes precedence over user messages. A user cannot simply type "ignore that rule" and expect the model to obey.
Three rules control how it behaves:
- Each one is added to the conversation history as its own step. Older instructions stay there.
- If two instructions clash, the newest one wins.
- The top-level system_instruction must stay the same on every turn.
To use it:
Send the first turn
Set your top-level system_instruction and your first user message. Save the interaction ID that comes back.
Add a system_input on a later turn
Put your new rule in a system_input step and point to the earlier turn with previous_interaction_id.
Send the user_input
Place your actual question after the system_input in the same request.
Here is the shape of such a request. Treat it as a sketch, and copy the exact field names from Google's example before you run it.
{
"model": "gemini-4-neon",
"previous_interaction_id": "ID_FROM_YOUR_LAST_TURN",
"system_instruction": "You are a patient coding tutor.",
"input": [
{
"type": "system_input",
"content": "From now on, answer in simple English. Keep each answer short."
},
{
"type": "user_input",
"content": "Why does my loop still print undefined?"
}
]
}
Debug one bug in a single live thread
Instead of pasting the same long context into a fresh request for every attempt, you keep one thread running and send a short system_input whenever you want the bot to behave differently.
Say you are building a small expense tracker for a college project. The total on the dashboard is wrong, and you cannot see why. You paste your component, the API handler and the console logs into the first turn. The model gives you a long, detailed answer.
That answer is hard to follow, so on the next turn you add a system_input: "Answer in simple English, in short sentences." The model switches style. Your code and logs are still there in the cached history, and you did not paste them again.
Later the model starts suggesting several fixes at once, and you lose track of which one worked. Near the end, you add a third rule: "Do not suggest new libraries. Use only what is already in my project."
Compare the two ways of working:
| Step | Old workflow | With system_input |
|---|---|---|
| Change the answer style | Start a new request, paste code and logs again | Send one short system_input |
| Add a "one fix at a time" rule | Rewrite the system prompt and restart | Send another system_input in the same thread |
| Keep earlier attempts | Lost unless you paste them back in | Still in the thread history |
The language and tone change mid-session while the context stays cached, as The Next Web describes the feature. For a student, this matters most on long threads. A thread with many failed attempts is exactly the one you do not want to rebuild.
Cached context costs less, and the feature has no extra fee
Tokens inside a system_input are billed at standard input rates, there is no separate fee, and the earlier turns stay eligible for cached-token rates, according to The Next Web's report.
Your bill on each turn has two parts. The new system_input and your new message are charged like any other input.
Neither source gives a dollar or rupee price, or a discount size. Check Google's current Gemini API pricing page before you plan a budget, because preview pricing can change. If you are also trying to cut token costs on large files, read my post on slicing files in the Gemini API.
Pros
- Long threads cost less, because old turns are charged at the cached rate.
- No restart, so you never re-paste code and logs.
Cons
- It is a preview, so field names and behavior may change.
- The newest instruction wins, which can quietly override a rule you set earlier.
Swap tools with added_tools and removed_tools
For a small agent, added_tools and removed_tools turn function tools on or off between turns, so you can remove a refund tool without reprocessing the conversation.
Both fields live inside the system_input step, as Google's post shows. Picture a support bot for an online shop. Early in the chat it can look up orders and issue refunds. Once the refund is done, you remove the refund tool so the bot cannot run it a second time.
{
"model": "gemini-4-neon",
"previous_interaction_id": "ID_FROM_YOUR_LAST_TURN",
"input": [
{
"type": "system_input",
"content": "The refund is complete. Only answer delivery questions now.",
"removed_tools": ["issue_refund"]
},
{
"type": "user_input",
"content": "When will my replacement arrive?"
}
]
}
Two limits apply. This works for function tools only, and MCP server tools are not supported. You must also keep the top-level tools list identical on every turn, and make changes only through added_tools and removed_tools.
Authorize every function call on your backend
Removing a tool in the prompt is not a security control, because Google says apps should still check every function call on the backend to guard against prompt injection.
Prompt injection means a user writes a message designed to trick the model into doing something it should not. Old instructions are never deleted from the thread. A carefully written user message could try to get the model to call a tool it once had.
Take an order-cancel function in a shop app, whether it sells phone cases in Pune or textbooks in Ohio. Before your server cancels anything, it should check three facts. Is the logged-in user the owner of this order? Has the order already shipped? Is this user allowed to cancel at all? If any answer is no, the server refuses, no matter what the model asked for.
What this changes for the agents you build
Agents can now change their rules as a task moves forward, so one long-running thread can replace several separate prompts that each had to carry the same context.
Think of a coding agent that first plans, then writes code, then reviews it. Before, each stage often became its own request with its own copy of the context. Now each stage can be a system_input in one Interactions API thread.
| Task | Old approach | system_input approach |
|---|---|---|
| Changing tools | New tools list, new request | added_tools or removed_tools |
Anthropic takes a different route to giving agents new abilities, covered in my post on Anthropic Skills over MCP. Comparing the two helps you see where each design fits.
To start today:
- Use the v1beta endpoint, since the feature is preview-only.
- Pick
gemini-4-neonto match Google's examples. - Test one real debugging thread before you build an agent on it.
- Keep the top-level system_instruction fixed on every turn.
Open the Google announcement, copy its gemini-4-neon example, and run it on a bug you are stuck on today: send one system_input to switch the answer style, and watch the thread keep going without a restart.