[Bug] System reminder prompt injection causes full KV cache miss during prefill phase
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Dynamic <system-reminder> strings injected mid-conversation cause a prompt prefix cache miss on local model servers (such as omlx) probably on anthropic endpoints too. This forces a full re-prefill step (e.g., re-processing over 40,000 tokens), degrading response latency and breaking prompt caching functionality.
What Should Happen?
The prompt prefix should match the stored KV cache across conversation turns, allowing high token cache reuse without triggering a full context re-prefill pass when system notifications or reminders are appended.
Error Messages/Logs
omlx.scheduler: Prompt prefix divergence detected at token 11176.
Expected: ... This is just a gentle reminder - ignore if not applicable.<|im_end|>
Received: ... This is just a gentle reminder - ignore if not applicable.\n\nThe task tools haven't been used recently...
Re-prefilling 42,218 tokens.
Steps to Reproduce
- Run a multi-turn session using Claude Code CLI connected to an Anthropic API endpoint / proxy that enforces prompt prefix caching.
- Allow the session to progress or sit idle until Claude Code injects an automated system reminder or attachment (e.g.,
<system-reminder>notifying that task tools haven't been used recently). - Observe the backend API logs / prompt token trace for the next request.
- Notice that the injected reminder string alters the exact prefix sequence mid-conversation, causing a prefix cache miss and forcing a full re-prefill of prior context tokens.
Claude Model
Other
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.201 (Claude Code)
Platform
Other
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Setting CLAUDE_CODE_DISABLE_ATTACHMENTS=1 or disabling dynamic system attachments in the client configuration prevents these dynamic system prompts from being inserted mid-turn, which temporarily resolves the prefix cache miss issue.