claude-code - 💡(How to fix) Fix Auto-compact resume executes stale plan file injected via system-reminder, causing context switch [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52530Fetched 2026-04-24 06:04:43
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Root Cause

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.

RAW_BUFFERClick to expand / collapse

What happened

After an auto-compact during an active conversation, the resume payload included:

  1. A summary of what we were actually working on (Task A: editing Figma mockups v2).
  2. A system-reminder pointing 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-reminder plan 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

  1. Start a plan-mode session for Feature X. Implement and commit it in that session.
  2. Later, in a new session, start work on Feature Y.
  3. Let the conversation grow until auto-compact fires.
  4. 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)

extent analysis

TL;DR

The model should be updated to prioritize the active conversation summary over stale plan files from prior sessions or include a freshness signal to determine the plan's relevance.

Guidance

  • Review the auto-compact logic to prevent injecting stale plan files from unrelated prior sessions.
  • Consider adding a freshness signal (e.g., timestamp, session ID) to plan files to help the model determine their relevance.
  • Update the model to prioritize the active conversation summary when a system-reminder plan file conflicts with it.
  • Investigate implementing a confirmation mechanism before switching contexts when a conflicting plan file is detected.

Example

No code snippet is provided as the issue does not contain specific code references.

Notes

The issue seems to be related to the model's handling of plan files and conversation context. The provided information suggests that the model is treating stale plan files as active directives, causing context switching and wasted conversation turns.

Recommendation

Apply a workaround by modifying the auto-compact logic to exclude stale plan files or adding a freshness signal to plan files, as this seems to be the root cause of the issue. This will help prevent the model from treating unrelated plan files as active directives.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING