feat: fire session reset hooks for daily and idle resets#2045
Open
BingqingLyu wants to merge 1 commit into
Open
feat: fire session reset hooks for daily and idle resets#2045BingqingLyu wants to merge 1 commit into
BingqingLyu wants to merge 1 commit into
Conversation
Wire internal hooks and before_reset plugin hook into the lazy staleness path so they fire on daily (4AM) and idle-timeout resets, not just manual /new and /reset commands. Both hooks fire as fire-and-forget to avoid blocking the user's message response (session-memory's LLM slug generation can take up to 15s). commands-core is dynamically imported inside the fire-and-forget block to avoid pulling its heavy dependency tree into session.ts's static imports. Export loadBeforeResetTranscript from commands-core for use by session.ts. Update bundled session-memory hook registration and filter to accept "daily" and "idle" actions. Fixes openclaw#10142, openclaw#31266, openclaw#50891, openclaw#43524 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
before_resetplugin hook only fire for manual/newand/resetcommands, not for daily (4AM) or idle-timeout session resets. This meanssession-memorynever saves on daily/idle resets.initSessionState(), updatesession-memoryregistration and filterexportadded to existing functionsChange Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
initSessionState()firessession_end/session_startplugin hooks for lazy resets but never firestriggerInternalHookorhookRunner.runBeforeReset. These only fire viaemitResetCommandHooks()incommands-core.ts, which is only called for manual/newand/resetcommands.Regression Test Plan (if applicable)
src/auto-reply/reply/session.stale-hooks.test.ts(new),src/hooks/bundled/session-memory/handler.test.ts(extended)action: "daily"/"idle"when session is stale;before_resetplugin hook fires for lazy resets; no double-fire on manual resettriggerInternalHookandhookRunnerto assert dispatch without side-effectssession-hooks-context.test.tscoverssession_end/session_startbut not internal hooks orbefore_resetUser-visible / Behavior Changes
session-memorynow saves session summaries on daily (4AM) and idle-timeout resets, not just manual/newand/reset. Pluginbefore_resethook now fires for lazy resets, giving plugins pre-archive transcript access.Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
session-memorysaves a summary of the previous sessionbefore_resetplugin hook fires withreason: "daily"and transcript messagesActual (before this PR)
session-memorydoes not fire — no summary savedbefore_resetplugin hook does not fireEvidence
Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations
before_resetreceives the post-archivesessionFilepath (afterrenameSync), not the original path.loadBeforeResetTranscripthandles ENOENT by scanning for the latest.reset.*archived sibling.AI Disclosure
🤖 AI-assisted with Claude Code
cc @vincentkoc (hooks/plugins CODEOWNER)