fix(compaction): count compact_boundary markers instead of inferring from context-% drops#425
Open
CorticalCode wants to merge 4 commits into
Open
fix(compaction): count compact_boundary markers instead of inferring from context-% drops#425CorticalCode wants to merge 4 commits into
CorticalCode wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rops Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…wording Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Compaction Counter (#282) infers compactions from drops in
used_percentagebetween renders. The heuristic is fragile: it samples a noisy, debounced signal and guesses about discrete events. Known failure: transientused_percentage: 0frames create false counts — #370 (thanks @KorenKrita) patches that symptom with a sub-1% guard, but the problem class is inherent to inference: missed events between renders, window-size changes, and persisted prev-state that can go stale.What
Count the explicit
{"type":"system","subtype":"compact_boundary"}records Claude Code writes to the session transcript at every compaction. Exact, stateless, retroactive. Records withisSidechain: true(a subagent compacting its own context) are excluded, matching the main-chain convention already used injsonl-metrics.ts. Display is unchanged (↻ N). The heuristic, its zod schema, threshold logic, and the per-session cache under~/.cache/ccstatusline/compaction/are deleted — net −319 lines. Marker format verified stable across transcripts from v2.1.92 → v2.1.170, for bothautoandmanualtriggers (v2.1.170 adds extracompactMetadatafields, buttype/subtype/isSidechainare unchanged).Behavior notes
--resume/--continue(markers live in the session's transcript file).transcript_path, like every other transcript metric.~/.cache/ccstatusline/compaction/become inert; they're left in place, consistent with how the existing per-session skills cache is handled.Testing
grep -cmarker counts — old code shows a false↻ 1on a flash frame; this branch shows↻ 0(no markers) and exactly↻ 2(two markers + flashes + a sidechain marker).