openclaw - 💡(How to fix) Fix [Feature]: Support before_reset hook for automatic daily session reset [1 comments, 2 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#74304Fetched 2026-04-30 06:25:51
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Author
Timeline (top)
closed ×1commented ×1cross-referenced ×1labeled ×1

Extend before_reset hook to fire on automatic daily session resets (4 AM), enabling session-memory to auto-save context before session wipe.

Root Cause

Extend before_reset hook to fire on automatic daily session resets (4 AM), enabling session-memory to auto-save context before session wipe.

RAW_BUFFERClick to expand / collapse

Summary

Extend before_reset hook to fire on automatic daily session resets (4 AM), enabling session-memory to auto-save context before session wipe.

Problem to solve

OpenClaw's automatic daily session reset at 4 AM silently wipes conversation context with no pre-reset hook. The built-in session-memory hook only listens to command:new and command:reset (manual triggers). Even the Plugin hook before_reset only covers manual resets. When a conversation is interrupted by the 4 AM daily reset, there is no opportunity to auto-save context — the new session starts with zero context and valuable information is lost.

Proposed solution

Extend the existing Plugin hook on('before_reset', ...) to also fire during automatic daily session resets, with an additional event.context.isAutomatic boolean flag set to true. This mirrors the compaction pattern (session:compact:before + memoryFlush) and allows plugins/internal-hooks to run cleanup code (save context to memory/YYYY-MM-DD.md, notify channels) before the session is wiped.

Alternatives considered

  1. Change reset time to daytime (session.reset.atHour: 8): Reduces probability but does not solve the core problem.
  2. Use idle mode instead of daily mode: Changes session reuse semantics; unacceptable.
  3. Manual /new before sleep: Relies on human discipline; unreliable.
  4. Post-reset recovery via MEMORY.md: Only helps if context was actually saved before reset.

Impact

Affected: OpenClaw users relying on session continuity across daily resets. Severity: High — data loss with no recovery opportunity. Frequency: Daily at 4 AM if user is active. Consequence: Valuable context is silently wiped; agents cannot save working memory; users lose mid-task progress with no notification.

Evidence/examples

session-memory hook only listens to command:new and command:reset — verified via HOOK.md source code. Plugin hook before_reset also excludes automatic daily reset. Compaction fires session:compact:before + memoryFlush before automatic compaction, but daily reset has no equivalent. OpenClaw version 2026.4.25.

Additional information

The proposed flag event.context.isAutomatic = true allows hook implementers to distinguish automatic from manual resets without breaking existing before_reset behavior. This is backward-compatible and only adds new behavior without changing existing behavior.

extent analysis

TL;DR

Extend the before_reset hook to fire on automatic daily session resets by adding an event.context.isAutomatic flag.

Guidance

  • Review the HOOK.md source code to understand the current session-memory hook behavior and its limitations.
  • Consider implementing the proposed event.context.isAutomatic flag to distinguish between automatic and manual resets.
  • Evaluate the impact of changing the reset time or using idle mode instead of daily mode, as discussed in the alternatives considered.
  • Test the extended before_reset hook with the new flag to ensure backward compatibility and correct behavior.

Example

// Example of the extended before_reset hook with the new flag
on('before_reset', (event) => {
  if (event.context.isAutomatic) {
    // Handle automatic daily session reset
    saveContextToMemory();
  } else {
    // Handle manual reset
    // Existing code here
  }
});

Notes

The proposed solution requires careful testing to ensure that the new event.context.isAutomatic flag does not break existing behavior and correctly handles both automatic and manual resets.

Recommendation

Apply the proposed workaround by extending the before_reset hook with the event.context.isAutomatic flag, as it provides a backward-compatible solution that addresses the core problem of silent context loss during automatic daily session resets.

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

openclaw - 💡(How to fix) Fix [Feature]: Support before_reset hook for automatic daily session reset [1 comments, 2 participants]