fix(cli): compact before configured context threshold - #11010
Merged
Conversation
chrarnoldus
approved these changes
Jun 8, 2026
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewBoth issues from the previous review have been resolved in the latest commits:
The Files Reviewed (5 files)
Fix these issues in Kilo Cloud Reviewed by claude-4.6-sonnet-20260217 · 853,271 tokens Review guidance: REVIEW.md from base branch |
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
fix(cli): compact before configured context threshold
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.
Provider-reported token usage is only available after a response and can be missing or inaccurate, so the configured auto-compaction threshold could be crossed without compaction. Kilo could then send an oversized request and recover only after the provider returned a context-limit error.
This change estimates the assembled outgoing request before provider dispatch, including conversation text, system instructions, and tool schemas. It starts compaction when that estimate reaches
compaction.threshold_percentor the existing reserved safety limit, whichever comes first, while retaining provider overflow handling as a fallback.Preflight replay preserves media attached to the current user turn. Tool-result continuations skip proactive replay so completed tools are not executed twice, and conservative raw media accounting remains in place when capping output tokens.
Related user issue: #9605