Compaction summarizes Skill-loaded content instead of clearing it — wastes context and risks silent format drift
Summary
When a task-oriented Skill is invoked via the Skill tool (i.e. a normal skill the agent chooses to invoke on demand — not a "mode"-style skill with disable-model-invocation: true that represents persistent on/off state, which is a different mechanism covered by #72549), its SKILL.md content (base directory + full instructions) is injected into the conversation as a tool result. We observed that this injection is not cached or deduplicated — every single invocation of the same skill re-injects the identical full content. We verified this directly: across 5 separate invocations of the same skill spanning multiple days within one long-running session, the injected content was byte-length-identical every time. This strongly suggests the intended usage pattern is that the agent is expected to re-invoke the Skill tool fresh every time it needs the skill's instructions, not rely on anything retained from an earlier invocation in the conversation.
However, when conversation compaction occurs, the Skill's injected content is not treated any differently from ordinary conversational narrative — it gets folded into the general semantic summary like everything else. We examined all 4 compaction events (compact_boundary) within one long-running session (via compactMetadata.preservedMessages) and found that none of the resulting summaries preserved any of the skill's actual formatting/instructional details (specific required phrasing, a required URL query parameter, output-formatting constraints, "respond with exactly one message" type rules, etc.). Only generic operational facts survived consistently across all 4 (a script path, some JSON field names, an upload destination) — never the "how to format the output" instructions themselves.
Why this looks like a bug rather than intended behavior
Given that a fresh, complete reload of the Skill's content is required every time regardless (shown by the byte-identical re-injection above), the compacted/degraded summary of that content provides no benefit once compaction happens:
- If the agent behaves as normally observed and re-invokes the Skill tool before using it again, the summarized residue is simply never read — pure wasted context tokens, no upside.
- If the agent does not re-invoke the Skill tool (see the observed case below), the summarized residue can create a "false-confidence" failure mode: the agent proceeds as if it has all the information it needs, when in fact the critical formatting details (required output format, URL parameters, message-count constraints, etc.) were never captured by the semantic summary to begin with. The result is output that looks plausible and passes a surface-level check, but silently violates the skill's actual contract.
We could not identify any scenario where retaining a semantically-summarized version of Skill content is actually helpful, since a full, accurate version is always one tool call away and is never expected to be reused verbatim from memory.
Observed case (details anonymized)
In a personal-assistant style long-running session (model claude-sonnet-4-6, spanning ~2.5 weeks, 4 automatic compactions total), a Skill is used to run a recurring scheduled task: generate a report, upload it, then send exactly one reply to the user following a required template — including appending a cache-busting query parameter to a link in that reply.
Across the session, the agent correctly re-invoked the Skill tool before performing this task on 5 separate occasions. On one occasion, immediately after an automatic compaction had just occurred, the agent instead directly ran the skill's underlying script via a shell tool call (apparently from memory of a previous invocation), without invoking the Skill tool at all. The resulting reply to the user diverged from the required template and was missing the required cache-busting query parameter — consistent with the agent working from an incomplete/summarized memory of the format rather than the actual (by-then-discarded) instructions.
To clarify causation: we cannot confirm that the summarized/degraded Skill content directly caused the agent to skip invoking the Skill tool on this occasion. The event occurred near the session's auto-compaction threshold, though with only one occurrence we cannot establish causation from context pressure alone. What we can confirm is that once the Skill tool was skipped that time, the already-compacted context contained no usable formatting information for the agent to fall back on — only the degraded summary — which is at least consistent with the resulting output defect, even though we can't prove it's the root cause of why the Skill tool was skipped in the first place.
Suggested change
Treat Skill-loaded tool-result content as a distinct category during compaction: instead of applying the same semantic-summarization logic used for narrative conversation, clear it down to a minimal marker (e.g. "Skill <name> was invoked here") rather than attempting a semantic summary of its full instructions. This forces a fresh reload on next invocation, mirroring how Claude Code already handles oversized tool outputs elsewhere (replace with a placeholder, refetch on demand). Since Skill content is fully and identically reproducible on demand, discarding it cleanly loses no real information — it only removes a misleading partial summary that the agent has no way of knowing is incomplete.
Note on skill file changes: this proposal assumes skill files stay stable during a session. If a skill's SKILL.md or supporting files are edited mid-session, forcing a fresh reload on next use is actually the correct behavior — retaining a stale summary would be worse. So this isn't a real downside of the proposal, just worth naming explicitly.
What we checked before filing
- Confirmed byte-length-identical full Skill content re-injection across 5 separate invocations of the same skill, spanning multiple days, within the same session.
- Examined all 4
compact_boundaryevents in the session viacompactMetadata.preservedMessages/preservedSegment, confirming the Skill's instructional content was outside the small verbatim-preserved tail window every time, and that none of the resulting summaries contained any of the skill's specific formatting instructions. - Searched existing issues for overlap. Found several adjacent-but-distinct reports, none of which cover this specific mechanism:
- #20466, #43761/#40193 — skill invocations/triggers re-activating or re-executing after compaction (opposite direction: too much retained, not too little)
- #25994 — the general skill catalog listing gets duplicated after compaction (pure context waste, unrelated to a specific skill's instructional content)
- #72549 — a "mode"-style skill's body is misread as still-active after compaction because it auto-reloads every session/compaction regardless of the agent's tool-call decisions; different mechanism from task-oriented skills invoked on demand via the
Skilltool - #19471, #6354 — user reports of CLAUDE.md/skill behavior changing after compaction, but without first-hand metadata/timestamp evidence and without pinpointing this specific "lossy semantic summary → false-confidence recall" mechanism
Happy to share more detail (redacted session excerpts, exact timestamps, compactMetadata structure) if useful for reproducing or diagnosing this further.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗