Auto-compact resume executes stale plan file injected via system-reminder, causing context switch
What happened
After an auto-compact during an active conversation, the resume payload included:
- A summary of what we were actually working on (Task A: editing Figma mockups v2).
- A
system-reminderpointing at a plan file from a prior plan-mode session for an unrelated feature (Task B: implementing a new CLI subcommand).
The reminder text said:
A plan file exists from plan mode at: /Users/.../.claude-work/plans/elegant-swimming-avalanche.md If this plan is relevant to the current work and not already complete, continue working on it.
The model treated that line as an instruction and started working on Task B instead of Task A. In my case Task B had already been fully implemented and committed (git log showed the commit), so the model ended up verifying a no-op for an entire turn — fetching the plan file, reading the referenced source files, checking git, writing a trivial docstring polish — before the user noticed the context switch and corrected it.
The actual user-facing task (Task A) stalled for one full roundtrip.
Expected behaviour
One of:
- Auto-compact should not inject stale plan files from unrelated prior sessions as if they were live work.
- When a
system-reminderplan file conflicts with the active conversation summary, the model should prioritise the summary, or at minimum confirm with the user before switching contexts. - The reminder should include a freshness signal (timestamp, session id) so the model can judge \"is this plan still live?\" instead of trusting the imperative phrasing.
Repro shape
- Start a plan-mode session for Feature X. Implement and commit it in that session.
- Later, in a new session, start work on Feature Y.
- Let the conversation grow until auto-compact fires.
- On resume, the Feature X plan file can be re-surfaced as an active directive.
Ask
Beyond fixing the root cause, it would be fair to offer token/context compensation when a full conversation turn is wasted because of injected stale state that the user had no way to prevent.
Environment
- Claude Code CLI
- Model:
claude-opus-4-7 - Platform: macOS (darwin 25.4.0)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗