openclaw - 💡(How to fix) Fix Feature Request: session:end hook + autoDream equivalent capabilities [1 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#60514Fetched 2026-04-08 02:50:08
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Based on the Claude Code open-source release (npm @anthropic-ai/claude-code), there are several core session lifecycle features that are currently missing from OpenClaw.

Root Cause

Based on the Claude Code open-source release (npm @anthropic-ai/claude-code), there are several core session lifecycle features that are currently missing from OpenClaw.

RAW_BUFFERClick to expand / collapse

Feature Request: Session Lifecycle Hooks & Claude Code-style Auto-Dream

Context

Based on the Claude Code open-source release (npm @anthropic-ai/claude-code), there are several core session lifecycle features that are currently missing from OpenClaw.

Requested Features

1. session:end Hook (Critical) Currently available hooks: command:stop, agent:bootstrap, gateway:startup. Missing: session:end — fires when a conversation session ends (user disconnect, timeout, explicit /new, or graceful /stop completion).

Use case: Run self-eval scripts to detect user corrections, tool failures, escalation triggers → write to reflection memory → feed into evolve rule extraction.

2. autoDream / Session Consolidation Claude Code implements automatic dream consolidation: when ≥24h elapsed + ≥5 sessions accumulated, triggers a 4-stage整合 workflow:

  • Orient → Gather → Consolidate → Prune

This enables continuous self-improvement without manual intervention.

3. Fork Cache Reuse Claude Code allows forked sub-agents to reuse the parent's prompt cache, significantly reducing context window overhead. OpenClaw's subagent forking does not currently support this optimization.

4. Context Expiration & Auto-Pruning Claude Code automatically prunes oldest context when approaching token limits. OpenClaw lacks a built-in mechanism for context window management at the session level.

Priority

From a user perspective, session:end is the highest-impact missing piece — it's the foundation for self-evaluating agents and continuous learning.

Alternatives Considered

  • command:stop only fires on explicit user /stop, not on timeout/disconnect
  • agent:bootstrap fires on new agent start, not session end
  • Cron-based polling is unreliable for detecting session boundaries

Environment

OpenClaw version: latest (2026.04) Plugin: memory-lancedb-pro for long-term memory Platform: macOS / Linux

extent analysis

TL;DR

Implementing a session:end hook is likely the most critical step towards addressing the missing features in OpenClaw, enabling the development of self-evaluating agents and continuous learning capabilities.

Guidance

  • Investigate the feasibility of introducing a new hook, session:end, which would fire when a conversation session ends due to user disconnect, timeout, explicit /new, or graceful /stop completion.
  • Review the existing hooks (command:stop, agent:bootstrap, gateway:startup) to understand their limitations and how they differ from the proposed session:end hook.
  • Consider the potential integration of auto-dream consolidation, as seen in Claude Code, to enable continuous self-improvement without manual intervention.
  • Evaluate the current context window management in OpenClaw and explore options for implementing automatic pruning of oldest context when approaching token limits.

Example

No specific code example can be provided without further details on the OpenClaw architecture and plugin ecosystem. However, the implementation of the session:end hook could involve modifying the session management logic to trigger a callback function when a session ends.

Notes

The implementation of these features may require significant changes to the OpenClaw core or plugin architecture. Additionally, the integration of auto-dream consolidation and context expiration mechanisms may introduce new complexities and potential issues.

Recommendation

Apply a workaround by implementing a custom solution for detecting session endings and triggering self-evaluation scripts, as the introduction of a new session:end hook may require significant changes to the OpenClaw core. This workaround can be used until a more comprehensive solution is developed and integrated into the OpenClaw platform.

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