-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Bug: in-turn auto-compaction can bypass memoryFlush because memoryFlush only runs pre-turn #62420
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.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:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.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
Summary
When
agents.defaults.compaction.memoryFlush.enabled=true, OpenClaw can still perform an in-turn auto-compaction without writing any memory files.The root cause appears to be that
runMemoryFlushIfNeeded()only runs before the turn starts, while some auto-compactions happen during the turn. In that case, compaction completes, but memory flush is never retried.Observed behavior
memory/*.mdwrite happens for that compaction cycle/statusmay still showCompactions: 0at some points, so the session transcript is a more reliable source than the status cardsession-memoryhook being disabled; that hook is only for/newand/resetExpected behavior
If
compaction.memoryFlush.enabled=true, then actual auto-compaction paths should not bypass memory flush.At minimum, one of these should happen:
memoryFlushonly applies to pre-turn checks and does not cover in-turn auto-compactionWhy this is happening (code path)
From the current runtime flow in
dist/agent-runner.runtime-C-sR1PRP.js:runPreflightCompactionIfNeeded(...)runMemoryFlushIfNeeded(...)In
runReplyAgent(...),runMemoryFlushIfNeeded()is called before the main turn execution.Later, during the actual turn, the runtime can emit compaction events (
evt.stream === "compaction"), and the session compaction count is incremented afterward — but there is no corresponding memory flush retry on that path.So the current behavior is effectively:
Impact
This creates a misleading configuration/behavior mismatch:
For users, this looks like "memoryFlush is enabled but does not actually protect all compaction cases".
Environment
compaction.mode: safeguardcompaction.memoryFlush.enabled: trueSuggested fix
Make runtime-triggered auto-compaction paths call the same flush logic (or a safe subset of it), instead of limiting
memoryFlushto pre-turn execution only.