fix: route timeout-recovery budget compaction through compactUntilUnder#270
Merged
fix: route timeout-recovery budget compaction through compactUntilUnder#270
Conversation
Regeneration-Prompt: | Phase 1 for lossless-claw issue #268. Timeout-recovery compaction was forcing budget-targeted recovery through compactFullSweep(), which only reasons over persisted context tokens. In the incident shape, live context was 277,403 tokens while stored context was already much smaller, so the forced sweep path could no-op on the wrong signal instead of using the capped compactUntilUnder() loop. Change only the routing needed for forced budget recovery. Preserve the existing full-sweep behavior for manual compaction requests and proactive threshold sweeps. Add focused regression coverage that proves the forced recovery path now calls compactUntilUnder() with the budget target and live token count, while threshold-target sweeps still stay on compactFullSweep(). Include a patch changeset because this is a user-visible bug fix.
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.
What
This PR fixes the Phase 1 regression behind issue #268 by routing forced timeout-recovery budget compaction through the capped
compactUntilUnder()flow instead of the one-passcompactFullSweep()path.Why
Forced recovery can be triggered by live context overflow even when persisted summary-store tokens are already small. Sending that path through
compactFullSweep()lets the recovery no-op on stored tokens and miss the live overflow signal, which is the incident shape captured in issue #268.Changes
compactUntilUnder()Testing
npx vitest run test/engine.test.ts -t "LcmContextEngine.compact token budget plumbing"npx vitest run test/engine.test.ts