-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Plugin context engines cannot increment /status compaction count #49380
Copy link
Copy link
Open
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:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.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
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:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.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.
Problem
/statusshows🧹 Compactions: 0for agents using plugin context engines (e.g. mem-engine, lossless-claw), even after hundreds of successful compactions.Root Cause
The
compactionCountdisplayed by/statuscan only be incremented through two paths:Mid-stream auto-compaction — when the built-in compaction fires during an agent run,
autoCompactionCountincrements and flows intoagentMeta.compactionCount, whichupdateSessionStoreAfterAgentRunreads. Plugin context engines that own compaction (ownsCompaction: true) bypass this path entirely because theirassemble()keeps context within budget, preventing overflow./compactslash command or overflow recovery — callscontextEngine.compact(), and if it returns{ ok: true, compacted: true },incrementCompactionCount()fires on the session store. This works, but/newresetscompactionCountto 0, and overflow rarely triggers becauseassemble()handles it proactively.Neither path captures leaf compactions — the primary compaction mechanism for plugin context engines. These run in
afterTurn()(background, fire-and-forget), and theContextEngine.afterTurn()interface:Promise<void>— return value is ignored by OpenClawEvidence
compaction_eventstable: 1,948 incremental leaf drains, 146 successful compactionscompactionCount: 0for all plugin-engine sessionsmainagent (legacy engine):compactionCount: 38— works because it uses mid-stream auto-compactionSuggested Fix
Add a compaction notification channel to the
afterTurncontract. Options:Option A (callback): Pass
notifyCompaction(count?: number)inafterTurnparams. Plugin calls it after each successful leaf/proactive compaction.Option B (return value): Change
afterTurnreturn type toPromise<void | { compactionCount?: number }>. OpenClaw reads and increments.Option C (direct read):
/statusqueries the context engine's own compaction tracking (e.g. via a newgetStats()method on theContextEngineinterface).Option A is probably cleanest — minimal contract change, plugin controls granularity.
Affected
ContextEngineplugin withownsCompaction: true