Repository navigation
fix: auto-compact from the TUI when context reaches 80% of the window - #1881
Merged
Merged
Conversation
Compaction was only reachable via /compact and the loop-detection third strike. Add shouldAutoCompact and autoCompactIfNeeded, which recount the context from the checkpointer and call handleCompact() once the status-bar token count reaches summarization.contextFraction (default 0.8) of the context window. Checked before each new message and after each turn. Pass the resolved contextWindow from App into ConversationArea.
6 of 12 tasks
avoidwork
added a commit
that referenced
this pull request
Nov 18, 2026
* fix: remove non-working summarization middleware PR #1881 moved auto-compaction into the TUI but left the library-replacing SummarizationMiddleware registered. Remove it, its onCompacted plumbing, and the trigger/keep/enabled config. Keep keepMessages and contextFraction, and make /compact and auto-compact honor keepMessages. * docs: restore DOCKER.md summarization env var table * fix: sync status bar color threshold with summarization.contextFraction The status bar spinner turned red at a hardcoded 80% while auto-compaction used config.summarization.contextFraction, so the two could drift apart. Pass contextFraction through App and InputArea to StatusBar so red starts exactly where auto-compaction fires. Take the fallback default from SummarizationSchema instead of duplicating 0.8 in the TUI.
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
Compaction was only reachable via
/compactand the loop-detection third strike, so long sessions could pass 90% context without compacting. The TUI now callshandleCompact()when the status-bar token count reachessummarization.contextFraction(default 0.8) of the context window, checked before each new message and after each turn. No middleware is involved.Type of Change
Testing
Added 6 unit tests for
shouldAutoCompact(exactly 80%, above, below, custom fraction, missing window or size, default constant) intests/unit/tui/conversationArea.test.js. The full suite passes through the pre-commit hook. TheautoCompactIfNeededwiring inside the component has no direct test, sinceconversationArea.jsis excluded from coverage and only its pure helpers are tested. Not yet exercised in a live multi-hour session.Limitation: the check runs between turns, not mid-turn, so one long tool-heavy turn can still cross the threshold before it fires.
Coverage
Checklist
npm run lintpassesThreat model: N/A. This is a UI-side trigger for an existing compaction path. It adds no new input, I/O or external calls.