-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Proactive compaction scheduler never re-fires after first checkpoint (compactionCount latched at 1) #63892
Copy link
Copy link
Closed as not planned
BingqingLyu/openclaw
#2272Closed as not planned
Copy link
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug: Proactive compaction scheduler never re-fires after first checkpoint
Summary
After a successful compaction, the proactive compaction scheduler never triggers again for the remainder of the session. Only an overflow-retry can force a second compaction. This causes sessions to grow from ~20k tokens back to 150k+ with zero proactive intervention.
Environment
Reproduction
Evidence from session metadata (
sessions.json)Key observation:
compactionCountis 1 despite 2 checkpoints in the array. The overflow-retry path creates checkpoints but does not appear to incrementcompactionCountcorrectly.Root Cause Hypothesis
The proactive compaction scheduler checks
compactionCount > 0(or similar latch) to decide whether compaction has already been performed this session. After the first compaction setscompactionCount = 1, the scheduler considers itself "done" and never re-evaluates — even as the session grows well past the threshold again.compactionCountshould be a monotonic trigger counter that fires on each threshold crossing, not a one-shot latch capped at 1.Suggested Fix
currentTokens > (maxTokens - reserveTokensFloor)AND no compaction has occurred since the last threshold crossing.lastCompactionAtTokenCountinstead of (or in addition to)compactionCount, so the scheduler can detect that the session has grown past the threshold again after a successful compaction.compactionCountto keep the counter consistent with the checkpoint array.Impact
Without this fix, long-running sessions silently grow to context overflow, causing degraded performance and eventual errors — even when
reserveTokensFlooris configured to prevent exactly this.