Skip to content

Bug: before_compaction / after_compaction plugin hooks are never called #9527

@theo-CD

Description

@theo-CD

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

  1. Create a plugin that registers a before_compaction hook:
api.on("before_compaction", async (event) => {
  api.logger.info("before_compaction fired!");
  console.log("Messages:", event.messages?.length);
});
  1. Trigger compaction (fill context window or use /compact)

  2. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions