Skip to content

Dreaming: spawned sessions not cleaned up after Gateway restart #78458

Description

@AnnieJun

Description

When Gateway restarts during a Dreaming cycle, the spawned child sessions (light/REM/deep phases) are not cleaned up and remain visible in the Control UI sidebar.

Expected Behavior

Dreaming calls deleteSession after each phase completes. These sessions should not persist across Gateway restarts.

Observed Behavior

After a Gateway restart during Dreaming, residual child sessions remain in the sidebar (6 orphaned sessions observed). They appear to be from phases that completed their work but whose cleanup deleteSession calls were lost when the Gateway process was killed.

Environment

  • OpenClaw: 2026.5.4
  • macOS (arm64)
  • Dreaming schedule: daily 00:30 (light → REM → deep)
  • Each phase uses sessions_spawn with a child session

Suggested Fix

On Gateway startup, consider scanning for orphaned Dreaming child sessions (e.g., sessions spawned by Dreaming that have already completed) and cleaning them up. Alternatively, use a more durable cleanup mechanism (e.g., mark sessions for deletion in a persistent store rather than relying on in-process deleteSession calls).

Workaround

Manual cleanup from the Control UI or openclaw sessions CLI.

/cc @steipete

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions