openclaw - 💡(How to fix) Fix Bug: Completed isolated sessions (dreaming-narrative) never evicted from in-memory session store [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#74906Fetched 2026-05-01 05:40:07
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
closed ×1commented ×1

The Memory Dreaming Promotion cron job spawns multiple isolated sub-sessions (deep/rem/light) each run. These sessions complete successfully (status: "done") but are never evicted from the Gateway's in-memory session store. Over time, they accumulate indefinitely.

Root Cause

The Memory Dreaming Promotion cron job spawns multiple isolated sub-sessions (deep/rem/light) each run. These sessions complete successfully (status: "done") but are never evicted from the Gateway's in-memory session store. Over time, they accumulate indefinitely.

Fix Action

Workaround

We have a cleanup cron (cleanup_dreaming.sh) that archives .jsonl transcript files from disk, but this does not remove the entries from the Gateway's in-memory session store. There is no API or mechanism to programmatically evict completed sessions from memory.

Code Example

sessions_list(search="dreaming")82 results
RAW_BUFFERClick to expand / collapse

Bug: Completed isolated sessions (dreaming-narrative) never evicted from in-memory session store

Description

The Memory Dreaming Promotion cron job spawns multiple isolated sub-sessions (deep/rem/light) each run. These sessions complete successfully (status: "done") but are never evicted from the Gateway's in-memory session store. Over time, they accumulate indefinitely.

Current Behavior

  • The Memory Dreaming Promotion cron runs daily at 03:00 and spawns ~20 isolated sub-sessions per run (3 types × ~7 memory fragments)
  • Each session completes in 7-25 seconds and marks as done
  • The session entries persist in the Gateway's in-memory session store forever
  • sessions_list returns all of them, growing unbounded

After 4 days of accumulation:

sessions_list(search="dreaming") → 82 results

Session breakdown by date:

  • 4/17: ~21 sessions (timestamps 1777230xxx)
  • 4/18: ~18 sessions (timestamps 1777316xxx)
  • 4/19: ~18 sessions (timestamps 1777402xxx)
  • 4/30: ~21 sessions (timestamps 1777489xxx)
    • 2 cron driver sessions

Expected Behavior

Completed isolated sessions should be automatically evicted from the in-memory store after a reasonable TTL (e.g., 1 hour after completion, or immediately upon completion for ephemeral tasks).

Impact

  1. Memory leak: Each session entry holds ~20K-70K tokens of context metadata in memory
  2. sessions_list pollution: Makes it impossible to find active/relevant sessions
  3. Growing unboundedly: At ~20 sessions/day, this will accumulate thousands of entries over months

Workaround

We have a cleanup cron (cleanup_dreaming.sh) that archives .jsonl transcript files from disk, but this does not remove the entries from the Gateway's in-memory session store. There is no API or mechanism to programmatically evict completed sessions from memory.

Environment

  • OpenClaw version: 2026.3.8-nightly.3
  • Platform: macOS (Darwin arm64)
  • Gateway: local daemon on port 18789

Suggested Fix

Add automatic eviction for completed isolated sessions:

  • Option A: Auto-evict done/killed/timeout sessions from memory after a configurable TTL (default: 1h)
  • Option B: Add a sessions_evict or sessions_cleanup API endpoint to programmatically remove completed sessions
  • Option C: Limit in-memory session store to N most recent sessions per agent, evicting oldest first

Option A would be the most robust since it handles the general case without requiring external cleanup scripts.

extent analysis

TL;DR

Implementing an automatic eviction mechanism for completed isolated sessions, such as a configurable TTL, is likely to fix the memory leak and sessions_list pollution issue.

Guidance

  • Investigate implementing Option A: Auto-evict done/killed/timeout sessions from memory after a configurable TTL (default: 1h) to handle the general case without requiring external cleanup scripts.
  • Consider adding a sessions_evict or sessions_cleanup API endpoint (Option B) to programmatically remove completed sessions for more control over session management.
  • Evaluate limiting the in-memory session store to N most recent sessions per agent (Option C), evicting oldest first, as a potential workaround.
  • Review the current cleanup_dreaming.sh cron job to understand its limitations in addressing the in-memory session store issue.

Example

No specific code snippet can be provided without further details on the implementation, but an example of how a TTL-based eviction might be structured could involve setting a timestamp for when a session is marked as done and then periodically checking for sessions that have exceeded their TTL.

Notes

The choice between Option A, Option B, and Option C depends on the specific requirements and constraints of the system, including performance considerations and the need for fine-grained control over session eviction.

Recommendation

Apply Option A (auto-evict done/killed/timeout sessions after a configurable TTL) as it seems to be the most robust solution, handling the general case without requiring external scripts, thus addressing the memory leak and sessions_list pollution effectively.

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 Bug: Completed isolated sessions (dreaming-narrative) never evicted from in-memory session store [1 comments, 2 participants]