-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Description
Bug: before_compaction / after_compaction plugin hooks are never called
Description
The before_compaction and after_compaction hooks are defined in the plugin API and documented in the agent-loop docs, but they are never actually invoked during compaction.
Steps to Reproduce
- Create a plugin that registers a
before_compactionhook:
api.on("before_compaction", async (event) => {
api.logger.info("before_compaction fired!");
console.log("Messages:", event.messages?.length);
});-
Trigger compaction (fill context window or use
/compact) -
Observe that the hook never fires
Expected Behavior
The before_compaction hook should fire before compaction summarizes messages, passing the messages that are about to be compacted in the event payload.
Actual Behavior
The hook is never called. Searching the dist files shows runBeforeCompaction and runAfterCompaction are defined and exported, but never invoked in the compaction code path.
Evidence
# Functions are defined/exported
grep -rn "runBeforeCompaction" dist/ | grep -v "function\|async"
# Returns only export lines, no invocations
# Hooks are documented as working
# docs/concepts/agent-loop.md says:
# "before_compaction / after_compaction: observe or annotate compaction cycles."Use Case
Memory plugins need this hook to capture conversation content before it gets summarized away. Without it, there's no reliable way to persist full conversation history for long-running sessions.
Environment
- OpenClaw version: 2026.2.3-1 (stable)
- OS: macOS 15.7.3 (arm64)