Skip to content

Bug: Dreaming narrative sessions not cleaned up after completion #76691

Description

@rockytian-top

Description

Dreaming narrative sub-sessions (dreaming-narrative-light, dreaming-narrative-deep, dreaming-narrative-rem) are spawned during the memory dreaming process but never cleaned up after completion. Over time, these orphaned sessions accumulate and consume disk space.

Steps to Reproduce

  1. Enable memory-core dreaming plugin (dreaming.enabled: true)
  2. Let the gateway run for a few days with dreaming cron active
  3. Check sessions: you will see dozens of dreaming-narrative-* sessions that are all done/failed but never deleted

Expected Behavior

Dreaming narrative sub-sessions should be automatically cleaned up after their content has been processed (e.g., cleanup: "delete" in the spawn options, or a TTL-based cleanup mechanism).

Actual Behavior

Each dreaming run creates 3 sub-sessions (light, deep, rem) that persist indefinitely. After running for weeks, this results in hundreds of orphaned session files.

Evidence

From source code (dreaming-phases-DW9aQqXD.js), the narrative session key is built deterministically:

dreaming-narrative-${phase}-${workspaceHash}-${nowMs}

Each invocation creates a new unique session, but there is no corresponding cleanup logic. The buildNarrativeSessionKey function generates keys with timestamps but nothing ever removes them.

Environment

  • OpenClaw version: latest (installed via brew)
  • OS: macOS (Darwin 25.4.0, arm64)
  • Node: v25.9.0
  • Plugin: memory-core with dreaming.enabled: true

Suggested Fix

Either:

  1. Add cleanup: "delete" to the dreaming narrative sub-agent spawn call
  2. Or add a TTL-based cleanup that removes dreaming sessions older than N hours after completion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions