Repository navigation
fix(core): keep the compaction tail within its keep allowance - #59305
Closed
xxwtiancai wants to merge 1 commit into
Closed
xxwtiancai wants to merge 1 commit into
xxwtiancai wants to merge 1 commit into
Conversation
Manual compaction could keep far more than keep.tokens verbatim beside the summary: recentStart walked the tail back to the nearest earlier user message, keeping a long autonomous run whole, and an oversized newest entry was always kept. The walk back now only happens while the tail stays inside the allowance, and an oversized newest entry is summarized instead of kept. Closes anomalyco#54910
Contributor
|
Thanks for tracking this down and for re-running the reproduction from #54910. I think this duplicates an existing open pull request:
Your version can start the tail partway through an assistant run instead of keeping only whole user exchanges, so it can keep some recent text where #53233 would keep none. If you think that matters, please raise it on #53233. A review there, your 66k → 5.9k numbers or your regression tests would all help. |
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 #54910
Type of change
What does this PR do?
Manual compaction could keep far more than
keep.tokensverbatim beside the summary.recentStartwalked the kept tail back to the nearest earlier user message, so a long autonomous run after the last user message was kept whole, and an oversized newest entry was always kept anyway. Running the repro script from the bot's comment ondev(e0b6039e1), the first request after/compactwas 65,952 tokens with the ~60k turn verbatim.The walk back to a user message now only happens while the tail stays inside the allowance, and a newest entry that alone exceeds it is summarized instead of kept. When neither applies, the tail starts at the newest entries that fit, mid-run if needed — each assistant message already carries its own tool calls and results, so a mid-run start does not split them.
One deliberate behavior change: an oversized newest exchange is no longer always kept verbatim (it is covered by the summary instead). The
summary compaction flattens the whole conversation…test was updated for that.How did you verify your code works?
packages/core/test/session-compaction.test.ts: an oversized newest turn leaves nokeepID/recenttext, and a tail over the allowance starts at the newest fitting reply instead of walking back past it./compactdropped from ~66k tokens (turn verbatim) to ~5.9k (summary only).ToolDefinitionimport error ondev(test/session-model-request-hooks.test.ts).Screenshots / recordings
Not a UI change.
Checklist