claude-code - 💡(How to fix) Fix Auto-compact re-injects prior skill invocations with new user message as Input [1 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#51937Fetched 2026-04-23 07:40:55
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×5closed ×1

After auto-compaction, the next turn's <system-reminder> lists skills (e.g. /loop) that were invoked before compaction, but pairs them with the new user message under ## Input — making it look as if the user just invoked the skill on this turn. The model follows the skill's instructions and executes side effects the user didn't request.

For /loop this creates an unwanted recurring cron job and immediately runs the prompt.

Root Cause

After auto-compaction, the next turn's <system-reminder> lists skills (e.g. /loop) that were invoked before compaction, but pairs them with the new user message under ## Input — making it look as if the user just invoked the skill on this turn. The model follows the skill's instructions and executes side effects the user didn't request.

For /loop this creates an unwanted recurring cron job and immediately runs the prompt.

RAW_BUFFERClick to expand / collapse

Summary

After auto-compaction, the next turn's <system-reminder> lists skills (e.g. /loop) that were invoked before compaction, but pairs them with the new user message under ## Input — making it look as if the user just invoked the skill on this turn. The model follows the skill's instructions and executes side effects the user didn't request.

For /loop this creates an unwanted recurring cron job and immediately runs the prompt.

Repro

  1. In a session, invoke /loop <something> at some point.
  2. Keep going until auto-compaction triggers.
  3. After the compaction summary, send any plain message (no slash command).
  4. Observe the next assistant turn: the system-reminder shows ### Skill: loop with your plain message under ## Input, and the assistant proceeds to schedule a cron + run the prompt.

User has observed this every time after auto-compaction, across multiple projects (not project-specific).

Expected

Stale skill invocation state should not be re-injected post-compaction with the new user message rebound as Input. Either drop the skill state, or label it clearly as "invoked earlier this session" so the model doesn't treat the new message as fresh skill input.

Actual

The skill block is presented as if freshly invoked. There is no signal to distinguish "invoked now" from "invoked pre-compaction with stale Input swap".

Impact

Worst for skills with immediate side effects (/loop schedules a cron; others might write files, post messages, etc.). Likely invisible for purely advisory skills.

Environment

  • Claude Code: 2.1.117
  • OS: Linux 6.11.0-1014-lowlatency
  • Model: claude-opus-4-7
  • Skill that misfired: /loop (bundled)

extent analysis

TL;DR

The issue can be mitigated by modifying the system to clearly label or drop stale skill invocation state after auto-compaction, preventing the model from treating new user messages as fresh skill input.

Guidance

  • Investigate the auto-compaction process to understand how skill invocation state is handled and identify why stale state is being re-injected with new user messages.
  • Consider adding a mechanism to label skill invocations as "stale" or "pre-compaction" to distinguish them from fresh invocations, allowing the model to ignore or handle them differently.
  • Review the /loop skill and other skills with immediate side effects to determine if they can be modified to check for stale invocation state before executing actions.
  • Verify that the issue is not specific to the /loop skill by testing other skills with immediate side effects after auto-compaction.

Example

No code snippet is provided as the issue does not include specific code details, but an example of how to label stale skill invocations could be:

# Pseudo-code example
if skill_invocation.is_stale:
    # Handle stale invocation, e.g., ignore or log a warning
    pass
else:
    # Handle fresh invocation, e.g., execute skill actions
    execute_skill_actions()

Notes

The issue seems to be related to the auto-compaction process and how it handles skill invocation state. Without more information about the implementation, it's difficult to provide a specific fix. The guidance provided is based on the assumption that the issue is due to the re-injection of stale skill invocation state after auto-compaction.

Recommendation

Apply a workaround by modifying the system to handle stale skill invocation state, as the root cause of the issue is likely related to the auto-compaction process and not a specific version or configuration issue.

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 Auto-compact re-injects prior skill invocations with new user message as Input [1 participants]