-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
memoryFlush never triggers when compactionCount and memoryFlushCompactionCount are both 0 #47143
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.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
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.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
Priority
None yet
Description
memoryFlushnever triggers for sessions that have never been compacted, becausehasAlreadyFlushedForCurrentCompactionincorrectly returnstruewhen both counters are 0.Root Cause
In
hasAlreadyFlushedForCurrentCompaction:When a session has:
compactionCount: 0(never compacted)memoryFlushCompactionCount: 0(never flushed, or explicitly set to 0)The function returns
0 === 0 → true, incorrectly indicating "already flushed", so flush is skipped.Observed Behavior
Expected: memoryFlush should trigger (tokens > threshold, never flushed)
Actual: memoryFlush skipped because
hasAlreadyFlushedForCurrentCompactionreturns trueSuggested Fix
Option A: Check for
undefinedseparately:Option B: Use
-1ornullas "never flushed" sentinel instead of0.Environment
Impact
All sessions that grow past the flush threshold but have never been compacted will never auto-flush, leading to unbounded context growth until manual intervention.
Related
See also #47111 (qmd auto-update not firing) - separate issue but discovered during same investigation.