Repository navigation
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Related PRs FoundPR #50537 -
PR #44264 -
Note: PR #50796 is your current PR and is shown in the results, but should not be considered a duplicate of itself. |
Veld101
force-pushed
the
compaction-usage-guard
branch
from
September 29, 2026 00:45
f8b9c29 to
95ebdb4
Compare
This branch has not been deployed
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.
Issue for this PR
Closes #50474
Type of change
What does this PR do?
SessionCompaction.requiredcomparesestimateTokens()against the buffered prompt ceiling and never checks that the reported usage is possible. In #50474 a provider reportedusage.inputof 25-33M against a model whose context window is 1,048,576.estimateTokens()sums the anchor message's reported tokens, so the comparison is true on every step, auto-compaction runs again, and the loop only stops when the session is interrupted.A real prompt cannot exceed the model's context window, so usage that does cannot be genuine and should not schedule a checkpoint. The guard runs before the ceiling comparison and only rejects impossible reports; a prompt that exactly fills the window still compacts. Genuine overflow still recovers through the context-overflow failure path, so no recovery capability is lost.
I did not change
estimateTokensitself, which stays the pure size estimator the other call sites and tests rely on.How did you verify your code works?
Added assertions to the existing
auto compaction estimates current content against the buffered prompt ceilingtest:inputof 25,391,744 againstcontext: 1_048_576returnsfalse1_048_576) still returnstrueRemoving the guard makes both assertions fail.
The full
packages/coresuite is 4736 pass / 27 fail. The failures reproduce on unmodifiedv2— I verified a sample with this change stashed — and are Windows environment issues (shell, git worktrees, config discovery), unrelated to this change.A V1 variant of the same fix is open as #50537. This PR is the
v2change for the report.Screenshots / recordings
Not a UI change.
Checklist