Skip to content

Daily reset doesn't trigger session-memory hook flush #43524

@big91987

Description

@big91987

Summary

Daily/scheduled session reset (when evaluateSessionFreshness() detects a stale session) does not trigger the session-memory hook to save conversation context to ~/.openclaw/workspace/memory/. Only manual /new or /reset commands trigger the hook.

Root Cause

In src/auto-reply/reply/session.ts, when a daily reset occurs (!freshEntry), a new session is created silently without firing any internal hooks:

// Line 378-379
} else {
  sessionId = crypto.randomUUID();  // Silent reset, no hook triggered
  isNewSession = true;
}

The session-memory hook only triggers on command:new or command:reset events:

// src/hooks/bundled/session-memory/handler.ts:199-204
const isResetCommand = event.action === "new" || event.action === "reset";
if (event.type !== "command" || !isResetCommand) {
  return;
}

Manual /new goes through commands-core.ts:281emitResetCommandHooks(), which triggers the hook. Daily reset bypasses this entirely.

Impact

Users lose conversation context summaries when sessions reset automatically at the configured session.reset.atHour (default 4am). The transcript is archived to .reset. files, but the LLM-generated summary in workspace/memory/ is never created.

Reproduction Steps

  1. Configure daily reset: openclaw config set session.reset.mode daily
  2. Chat in a session (e.g., Feishu DM) at 2am
  3. Wait until after 4am (or adjust system time)
  4. Send another message at 6am
  5. Observe: session resets automatically (new sessionId), but no new file in workspace/memory/
  6. Compare: Send /new manually → session-memory hook fires, memory file created

Expected Behavior

Daily/scheduled reset should also trigger session-memory hook (or equivalent flush mechanism) to save conversation context before rotating the session.

References

  • Related fix: commit 709dc67 (fixed transcript archival on daily reset, but not memory flush)
  • Hook handler: src/hooks/bundled/session-memory/handler.ts
  • Session init: src/auto-reply/reply/session.ts:354-379

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions