claude-code - 💡(How to fix) Fix Post-compaction: Claude resumes the prior user request instead of the most recent one

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…

After automatic conversation compaction, Claude frequently picks up the second-to-last user request and acts on it, instead of the most recent one. The behavior is consistent enough to be noticeable across sessions, not a one-off.

Root Cause

After automatic conversation compaction, Claude frequently picks up the second-to-last user request and acts on it, instead of the most recent one. The behavior is consistent enough to be noticeable across sessions, not a one-off.

RAW_BUFFERClick to expand / collapse

Environment

  • Claude Code CLI (terminal REPL, --dangerously-skip-permissions)
  • Model: Claude Opus 4.7 (claude-opus-4-7)
  • OS: Windows 11, bash shell

Summary

After automatic conversation compaction, Claude frequently picks up the second-to-last user request and acts on it, instead of the most recent one. The behavior is consistent enough to be noticeable across sessions, not a one-off.

Expected

After compaction, the next turn should execute against the latest user message. The compacted summary should preserve "what was just asked" as the active task.

Actual

The newest request gets dropped or deprioritized; Claude resumes work on the request immediately preceding it, as if the compaction boundary shifted the "current task" pointer back one turn.

Impact

  • Wasted turns re-asking
  • Risk of Claude silently executing stale intent (especially bad for autonomous / scheduled sessions where no human is watching the next turn)
  • Breaks trust in long sessions

Suspected area

Compaction summary generation: likely the "most recent user turn" isn't being held out of the summarization window, so it gets folded into history rather than staying as the live prompt.

extent analysis

TL;DR

The issue can be mitigated by adjusting the conversation compaction logic to preserve the most recent user request as the active task.

Guidance

  • Review the compaction summary generation code to ensure it correctly handles the most recent user turn, potentially by excluding it from the summarization window.
  • Verify that the "current task" pointer is not being shifted back one turn during compaction, causing the second-to-last user request to be acted upon instead of the latest one.
  • Investigate the --dangerously-skip-permissions flag's impact on compaction behavior, as it may be influencing the issue.
  • Test the compaction process with a controlled sequence of user requests to identify the exact point of failure.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The provided information suggests a logic error in the compaction summary generation, but without access to the code, it's difficult to provide a precise fix. The issue may be specific to the claude-opus-4-7 model or the Windows 11 environment.

Recommendation

Apply a workaround by modifying the compaction logic to preserve the most recent user request, as the root cause is likely related to the summarization process. This approach allows for a targeted fix without requiring a version upgrade or significant changes to the underlying system.

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

claude-code - 💡(How to fix) Fix Post-compaction: Claude resumes the prior user request instead of the most recent one