Skip to content

fix: route timeout-recovery budget compaction through compactUntilUnder#270

Merged
jalehman merged 1 commit intomainfrom
fix/issue-268-timeout-budget-recovery
Apr 5, 2026
Merged

fix: route timeout-recovery budget compaction through compactUntilUnder#270
jalehman merged 1 commit intomainfrom
fix/issue-268-timeout-budget-recovery

Conversation

@jalehman
Copy link
Copy Markdown
Contributor

@jalehman jalehman commented Apr 4, 2026

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-pass compactFullSweep() 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

Testing

  • npx vitest run test/engine.test.ts -t "LcmContextEngine.compact token budget plumbing"
  • npx vitest run test/engine.test.ts
  • Expect the compaction routing tests and full engine suite to pass

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.
@jalehman jalehman merged commit 8618ea7 into main Apr 5, 2026
2 checks passed
@jalehman jalehman deleted the fix/issue-268-timeout-budget-recovery branch April 5, 2026 14:02
@github-actions github-actions bot mentioned this pull request Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant