Skip to content

Feature: Pre-compaction hook for memory preservation #7175

@00ainick-cmd

Description

@00ainick-cmd

Problem

When conversation context gets too long, Clawdbot compacts it automatically. If the summary generation fails (or is incomplete), critical context is lost permanently.

Currently there's no warning before compaction happens, so the agent can't proactively save important information.

Proposed Solution

Add a pre-compaction hook that fires before context compaction begins:

  1. Clawdbot detects context approaching limit
  2. Fires a hook/event: pre-compaction (or calls a configured script/prompt)
  3. Agent has opportunity to:
    • Dump key decisions to files
    • Save action items
    • Update memory/context files
    • Confirm readiness
  4. Compaction proceeds
  5. Critical context is preserved in external files

Alternatives Considered

  • Manual discipline: Agent writes to memory files in real-time (current workaround, error-prone)
  • More frequent scheduled syncs: Still can miss fast-moving conversations
  • Larger context windows: Expensive, doesn't solve the fundamental problem

Use Case

Late-night planning session with important decisions. Scheduled memory sync ran at 21:00, conversation continued until 23:00 with key decisions. Context compacted overnight, summary failed, decisions lost.

With pre-compaction hook: Agent would have saved the decisions before compaction.

Additional Context

This would make Clawdbot agents significantly more reliable for long-running conversations and reduce the "amnesia" problem that frustrates users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions