fix(compaction): make sliding-window eviction token-aware - #4099
Closed
Ricky-7-Yan wants to merge 1 commit into
Closed
Ricky-7-Yan wants to merge 1 commit into
Ricky-7-Yan wants to merge 1 commit into
Conversation
Ricky-7-Yan
marked this pull request as ready for review
August 31, 2026 15:34
Contributor
|
This pull request was automatically closed because it does not meet our submission requirements. What failed:
Please use the repository template and provide the required AI disclosure, AI tool list, policy acknowledgment, and exact Human Verification phrase. |
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.
Summary
Fixes #3956.
planLocalSlidingWindowCompactionpreviously had no token budget when no persisted context-window limit existed, so it stopped at the first valid record-count cutoff. Tool-heavy tails could therefore retain most estimated tokens and trigger compaction again almost immediately.The planner now falls back to a proportional budget from the transcript estimate, while automatic pressure-driven compaction passes the provider-resolved context window when available. Explicitly configured limits retain precedence. The implementation also preserves the current 1014-line source-size baseline.
This draft revives the voluntarily closed #3980 on current
main; the earlier commits and investigation by @feiiiiii5 were reviewed and adapted, with the tightened file-size baseline handled here.Test plan
bun test src/backend/local/compaction.test.ts: 6 passed, 0 failed.bun run check: all 12 checks passed, including cycles, file-size, Biome, and TypeScript.AI Disclosure
AI Tool(s) Used
OpenAI Codex was used to inspect the issue and prior closed work, adapt the implementation to current
main, and run the focused and repository-wide validation.Human Verification
Pending the submitting human's review. This draft must not be marked ready until the human has read the diff, checked the AI Policy box above, and can truthfully add the repository's required verification statement.