claude-code - 💡(How to fix) Fix Compaction drift: 'Resume directly, do not ask questions' trailer causes silent task switching [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#48850Fetched 2026-04-16 06:49:14
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1

After /compact (auto or manual), the model can resume on a completely different task than what was active pre-compaction, with no signal to the user. In the worst case this has caused unauthorized production deploys (full repro below). The root cause is the combination of three signals in the compact prompt that bias the model toward picking any actionable continuation, plus a trailer that explicitly forbids verifying.

Root Cause

After /compact (auto or manual), the model can resume on a completely different task than what was active pre-compaction, with no signal to the user. In the worst case this has caused unauthorized production deploys (full repro below). The root cause is the combination of three signals in the compact prompt that bias the model toward picking any actionable continuation, plus a trailer that explicitly forbids verifying.

Fix Action

Fix / Workaround

I've prototyped option 3 locally as a SessionStart:compact hook (compact-rehydrate.sh) that injects multi-signal ground truth (last journal entry + journal age + recent file edits) and an explicit "ASK if signals diverge" protocol. It works, but feels like a workaround for a prompt-design issue.

Workaround for users hitting this today

Code Example

{
  "hooks": {
    "SessionStart": [{
      "matcher": "compact",
      "hooks": [{ "type": "command", "command": "~/.claude/hooks/compact-rehydrate.sh" }]
    }]
  }
}
RAW_BUFFERClick to expand / collapse

Summary

After /compact (auto or manual), the model can resume on a completely different task than what was active pre-compaction, with no signal to the user. In the worst case this has caused unauthorized production deploys (full repro below). The root cause is the combination of three signals in the compact prompt that bias the model toward picking any actionable continuation, plus a trailer that explicitly forbids verifying.

Repro

Long-running Claude Code session, model is mid-task on feature A. /compact fires. Resumed model:

  1. Receives the compact summary (lossy)
  2. Sees Skills restored (frontend-slides, deck-gen, ...) notice — historically loaded skills, NOT current intent
  3. Reaches Section 9 "Optional Next Step" of the compact prompt — last position, high attention
  4. Final trailer at compact/prompt.ts:359: "Continue the conversation from where it left off without asking the user any further questions. Resume directly..."

Result: model picks a continuation from the highest-attention skill or summary fragment and proceeds. If that's frontend-slides when the actual work was infrastructure, the model ships an executive deck instead of fixing the bug.

Real-world impact (last 24h on my workspace)

  • Incident 1: Mid-session on a Postgres migration. /compact fires. Model resumes on frontend-slides skill, generates a 996-line strategy.html executive deck, deploys it to production fly.io with auth bypass in middleware.ts. Twice.
  • Incident 2: Mid-session on frontend skill work. /compact fires. Model resumes on the previous topic (was journaled), abandons current work.

Both happened with users who had session journaling/observability — the drift was only caught after the fact via git log.

Why the model can't self-correct

The trailer at compact/prompt.ts:359 says verbatim: "do not ask the user any further questions". So even when the model has uncertainty about which task to resume, the prompt forbids verification. The model commits to something and ships.

Suggested fix

Three options, in order of effort:

1. Soft (low effort): Make the trailer conditional on summary confidence. If Section 9 ("Optional Next Step") was empty or marked "ambiguous", drop the "do not ask questions" instruction.

2. Medium: Add a confidence field to the summary writer's output. Trailer becomes: "If [confidence:high], resume directly. Otherwise, briefly confirm the active task with the user."

3. Robust: Allow SessionStart hooks with matcher: "compact" to inject a "verification protocol" that overrides the trailer when present. This already partially works (hookSpecificOutput.additionalContext lands before first API call), but the trailer's "do not ask questions" instruction still wins because it's positionally last. Adding precedence rules — or letting hooks suppress the trailer — would close the loop.

I've prototyped option 3 locally as a SessionStart:compact hook (compact-rehydrate.sh) that injects multi-signal ground truth (last journal entry + journal age + recent file edits) and an explicit "ASK if signals diverge" protocol. It works, but feels like a workaround for a prompt-design issue.

Workaround for users hitting this today

{
  "hooks": {
    "SessionStart": [{
      "matcher": "compact",
      "hooks": [{ "type": "command", "command": "~/.claude/hooks/compact-rehydrate.sh" }]
    }]
  }
}

Hook script reads the project's most recent ground-truth (journal, recent edits) and emits hookSpecificOutput.additionalContext with explicit "ASK if signals disagree" protocol. Happy to share if useful.

References

  • src/services/compact/prompt.ts:359 — the "Resume directly" trailer
  • src/services/compact/prompt.ts:76 — Section 9 "Optional Next Step" (high-attention last position)
  • src/utils/hooks.ts:3867-3891executeSessionStartHooks with source-based matchers
  • src/utils/sessionStart.ts:140-172additionalContext injection mechanism

extent analysis

TL;DR

The most likely fix for the issue is to modify the compact prompt trailer to conditionally allow user verification based on summary confidence or task ambiguity.

Guidance

  • The root cause of the issue is the combination of the compact prompt's design and the trailer's instruction to "Resume directly" without asking further questions, which leads the model to pick an actionable continuation without verifying the user's intent.
  • To mitigate this, consider implementing one of the suggested fixes, such as making the trailer conditional on summary confidence or adding a confidence field to the summary writer's output.
  • Users can apply a temporary workaround by using a SessionStart hook with a matcher: "compact" to inject a verification protocol that overrides the trailer.
  • When implementing a fix, verify that the model correctly resumes the intended task after compaction and that user verification is triggered when necessary.

Example

{
  "hooks": {
    "SessionStart": [{
      "matcher": "compact",
      "hooks": [{ "type": "command", "command": "~/.claude/hooks/compact-rehydrate.sh" }]
    }]
  }
}

This example shows how to configure a SessionStart hook to inject a verification protocol when the model resumes from a compacted state.

Notes

The suggested fixes and workaround assume that the issue is primarily caused by the compact prompt's design and the trailer's instruction. However, the actual root cause may be more complex, and additional investigation may be necessary to fully resolve the issue.

Recommendation

Apply the Soft (low effort) fix by making the trailer conditional on summary confidence. This approach is the most straightforward and least invasive, and it can help mitigate the issue while further investigation and testing are conducted.

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 Compaction drift: 'Resume directly, do not ask questions' trailer causes silent task switching [1 comments, 2 participants]