Repository navigation
feat: record Claude Code and Codex compactions; runaway context growth restarts at one - #372
Open
Mark Warren (ZeSnarf) wants to merge 1 commit into
Open
Mark Warren (ZeSnarf) wants to merge 1 commit into
Mark Warren (ZeSnarf) wants to merge 1 commit into
Conversation
…h restarts at one Claude Code compact_boundary lines and Codex compacted / compaction / context_compacted / ContextCompaction records now fill request.compaction(s) in the Copilot CLI shape: size before, after and trigger when logged, and for Codex the limit from model_context_window. Several Codex records for one compaction count once, and history a forked thread inherited adds none. Only numbers and enum values are kept, never the summary. Runaway Context Growth counts only the requests after a session's last successful compaction; sessions that never compacted are measured as before. Context Amnesia Risk skips Claude Code compactions when no context limit was logged, since the estimated window is sized from the session's own peak and would put every compaction near full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions
Bot
requested review from
TamasBoncz,
Aymen (aymenfurter) and
Sanjay Singh (san360)
November 3, 2026 21:27
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.
Description
Compactions are only read from Copilot CLI logs today. Claude Code and Codex sessions that compact show no compactions on Context Management. Runaway Context Growth also measures them across the compaction, so a long session that compacted and kept working is flagged as growing without limit.
This PR:
systemlines with subtypecompact_boundaryand theircompactMetadata(trigger,preTokens,postTokens,durationMs) intorequest.compaction(s), in the Copilot CLI shape (readCliCompaction,addTurnCompaction). A compaction logged before the first prompt goes to the first request.compactedlines,compactionresponse items,context_compactedevents andContextCompactionitems. Codex logs no sizes, so the size before is the prompt of the last model call, and the limit is itsmodel_context_windowwhen logged. Codex often writes several records for one compaction; they count once. History that a forked thread inherited adds none.CACHE_VERSION.We found this by running the extension on real Claude Code and Codex logs, where long sessions that compacted several times were flagged as runaway context growth.
Related Issues
None filed.
Checklist
npm run checkpasses (typecheck + lint + spellcheck + knip + tests)parser-claude-compaction.test.ts,parser-codex-compaction.test.ts;context-management.test.ts: runaway growth after a compaction, and amnesia on an estimated Claude Code window)