openclaw - 💡(How to fix) Fix [Feature]: feat: trigger session-memory hook on /compact command [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50991Fetched 2026-04-08 01:05:47
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×2labeled ×1
RAW_BUFFERClick to expand / collapse

Summary

Problem

Currently, the session-memory hook only triggers on /new and /reset commands. This means:

  1. Long conversations that get compacted lose their original context
  2. If a session ends without explicit /new/reset (e.g., gateway restart, process crash), nothing is recorded
  3. Users must remember to manually run /new to trigger the hook

Proposed Solution

Add command:compact as a trigger event for the session-memory hook.

Why This Makes Sense

ScenarioCurrent BehaviorWith Compact Trigger
Long conversation compactedContext compressed, original details lost✅ Record before compression, preserve details
Compact frequencyNo recordingAuto-generate more raw records
Session crash/restartLost if no /newBetter chance of preservation
The /compact moment is exactly when:
  • The conversation has accumulated enough value to need context cleanup
  • Original content is about to be compressed/lost
  • Recording would be most valuable

Implementation

Add command:compact to the hook's event listeners:

Problem to solve

// Current events: ['command:new', 'command:reset']

Proposed solution

// Proposed events: ['command:new', 'command:reset', 'command:compact']

Alternatives considered

No response

Impact

Affected users: All users who rely on session-memory hook for conversation archival, weekly reviews, or knowledge management workflows. Severity: Medium - Blocks workflow reliability. Users who depend on session logs for weekly reviews or memory search lose valuable context when sessions end without explicit /new. Frequency: High - In daily usage, /compact happens frequently (every 50k-100k tokens depending on configuration), while /new is easily forgotten. Estimate 70%+ of valuable sessions are lost due to this gap. Consequences:

  • Lost context: Original conversation details compressed away with no record
  • Incomplete memory: Weekly session log merges miss important sessions
  • Extra manual work: Users must remember to run /new periodically, or risk data loss
  • Workflow breakage: Automation pipelines that depend on session logs have gaps

Evidence/examples

No response

Additional information

No response

extent analysis

Fix Plan

To address the issue, we need to add command:compact as a trigger event for the session-memory hook. Here are the steps:

  • Update the events array in the hook configuration to include command:compact.
  • Example code:
// Before
const hookConfig = {
  events: ['command:new', 'command:reset']
};

// After
const hookConfig = {
  events: ['command:new', 'command:reset', 'command:compact']
};
  • Ensure the hook function is properly handling the new event type.

Verification

To verify the fix, you can:

  • Trigger a command:compact event and check if the session-memory hook is executed.
  • Verify that the original context is preserved and recorded before compression.
  • Test different scenarios, such as long conversations and session crashes, to ensure the hook is working as expected.

Extra Tips

  • Make sure to update any relevant documentation and automated tests to reflect the changes.
  • Consider adding logging or monitoring to track the performance and effectiveness of the updated hook.
  • Review other potential trigger events that may be relevant for the session-memory hook.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING