Back to library
AI
tutorial

Update System Instructions Mid-Stream to Preserve Cache Speed

Add new instructions mid-chat without slowing down the AI's response time.

Inject a new 'system' role message mid-conversation instead of editing the initial prompt to keep your responses fast via prompt caching.

Claude

The Scenario

You are halfway through a long research or coding session and realize you need to change the output format or add a new constraint. You want to avoid the delay caused by re-caching the entire document.

Before & after

The old way

Manually editing the top-level system prompt at the start of a conversation forces the AI to re-process the entire history. This causes a cache miss and adds 30–60 seconds of latency for long threads.

With AI

Append a system role message at the current turn to update instructions without breaking the cache. This maintains instant response times and takes less than 1 minute to implement.

The Prompt

[CONTINUE_CONVERSATION]
{
  "role": "system",
  "content": "From now on, provide all code examples in TypeScript instead of Python and ensure they follow strict functional programming principles."
}

Mid-conversation system messages allow you to introduce new constraints or instructions partway through a chat without invalidating the 'stable prefix' of your prompt cache.

Source

Claude Platform release notes - Claude Platform Docs
"The cached prefix stays the same, so the next request still reads it from cache, and the new instruction is still applied..."