memory-core: dreaming subagent lacks operator.admin to delete its own session
openclaw version: 2026.4.20 (commit 115f05d)
Pre-existing in: at least 2026.4.15
Summary
The dreaming cron in memory-core runs subagent.deleteSession() after generating
a narrative entry, but the embedded subagent runner is invoked without
operator.admin scope. Result: every dream cycle (light, REM, deep × number of
agents) emits narrative session cleanup failed: missing scope: operator.admin.
The narrative itself is generated and written successfully — only the
post-generation session cleanup fails, leaving stale session entries that have to
be cleaned externally.
Reproduction
-
Configure dreaming:
-
Wait for cron to fire (or trigger manually)
-
Observe in /tmp/openclaw/openclaw-YYYY-MM-DD.log:
memory-core: dreaming cleanup scrubbed 0 stale session entries and archived 42 orphan transcripts.
memory-core: narrative session cleanup failed for light phase: missing scope: operator.admin
memory-core: narrative session cleanup failed for rem phase: missing scope: operator.admin
memory-core: narrative session cleanup failed for deep phase: missing scope: operator.admin
Source location
dist/dreaming-narrative-D2j0t41s.js:597 (in 2026.4.20):
if (params.subagent) try {
await params.subagent.deleteSession({ sessionKey });
} catch (cleanupErr) {
params.logger.warn(`memory-core: narrative session cleanup failed for ${params.data.phase} phase: ${formatErrorMessage(cleanupErr)}`);
}
The subagent context is created by manager-runtime.js for the dreaming sweep
without admin scope. The deleteSession API path requires operator.admin per
server.impl-DYBxSjUs.js:10196 (ADMIN_SCOPE = "operator.admin").
Suggested fix
Either:
- Auto-grant
operator.admin to the subagent runner spawned by the dreaming cron
(it's the same trust boundary as the parent gateway, owns its own session).
- Provide a
subagent.deleteOwnSession() API that doesn't require admin scope
when called by the session's own creator.
- Use a separate cleanup path that doesn't go through the scope-gated HTTP delete.
Impact
- Repeated WARN log noise (multiple lines per dream cycle × multiple agents)
- Stale session entries accumulate; require external cleanup script
(prune-dream-sessions.sh cron at 03:30 UTC handles this for us)
managed dreaming cron could not be reconciled (cron service unavailable) —
related warning suggesting the dreaming control plane is partially broken too
Environment
- LXC container, Debian 12, Node 22.22.2
- 14 agents, dreaming enabled per agent
- Cron is running and working (
systemctl status cron shows active)
- Workaround: external
prune-dream-sessions.sh at 03:30 UTC catches what
the failed cleanup leaves behind
memory-core: dreaming subagent lacks
operator.adminto delete its own sessionopenclaw version: 2026.4.20 (commit 115f05d)
Pre-existing in: at least 2026.4.15
Summary
The dreaming cron in
memory-corerunssubagent.deleteSession()after generatinga narrative entry, but the embedded subagent runner is invoked without
operator.adminscope. Result: every dream cycle (light, REM, deep × number ofagents) emits
narrative session cleanup failed: missing scope: operator.admin.The narrative itself is generated and written successfully — only the
post-generation session cleanup fails, leaving stale session entries that have to
be cleaned externally.
Reproduction
Configure dreaming:
Wait for cron to fire (or trigger manually)
Observe in
/tmp/openclaw/openclaw-YYYY-MM-DD.log:Source location
dist/dreaming-narrative-D2j0t41s.js:597(in 2026.4.20):The subagent context is created by
manager-runtime.jsfor the dreaming sweepwithout admin scope. The
deleteSessionAPI path requiresoperator.adminperserver.impl-DYBxSjUs.js:10196(ADMIN_SCOPE = "operator.admin").Suggested fix
Either:
operator.adminto the subagent runner spawned by the dreaming cron(it's the same trust boundary as the parent gateway, owns its own session).
subagent.deleteOwnSession()API that doesn't require admin scopewhen called by the session's own creator.
Impact
(
prune-dream-sessions.shcron at 03:30 UTC handles this for us)managed dreaming cron could not be reconciled (cron service unavailable)—related warning suggesting the dreaming control plane is partially broken too
Environment
systemctl status cronshows active)prune-dream-sessions.shat 03:30 UTC catches whatthe failed cleanup leaves behind