Skip to content

memory-core: dream narrative cleanup warns missing operator.admin after nightly dreaming #72554

@richardmqq

Description

@richardmqq

Summary

memory-core nightly dreaming can leave repeated warning noise after dream narrative generation, because detached narrative subagent runs either time out or finish, then cleanup calls subagent.deleteSession({ sessionKey }) from the plugin path without sufficient gateway scope. The cleanup failure is logged as:

memory-core: narrative session cleanup failed for <phase> phase: missing scope: operator.admin

This appears to be an upstream plugin/runtime scope bug rather than a local configuration problem.

Environment

  • OpenClaw: 2026.4.24 (cbcfdf6)
  • Platform: macOS / Darwin arm64
  • Plugin: memory-core
  • Feature: nightly dreaming / dream narrative generation
  • Relevant config:
{
  "plugins.entries.memory-core.config.dreaming": {
    "enabled": true,
    "frequency": "0 3 * * *",
    "timezone": "Asia/Shanghai",
    "verboseLogging": true
  }
}

Observed behavior

On nightly dreaming runs, memory promotion itself completes, but log noise remains from narrative generation/cleanup.

Examples from ~/.openclaw/logs/gateway.err.log:

2026-04-27T03:00:16.523+08:00 [plugins] memory-core: narrative generation ended with status=timeout for light phase.
2026-04-27T03:00:16.523+08:00 [plugins] memory-core: narrative session cleanup failed for light phase: missing scope: operator.admin
...
2026-04-27T03:00:30.611+08:00 [plugins] memory-core: narrative generation ended with status=timeout for rem phase.
2026-04-27T03:00:30.611+08:00 [plugins] memory-core: narrative session cleanup failed for rem phase: missing scope: operator.admin

Counts from two recent days:

DAY 2026-04-26
7  managed dreaming cron could not be reconciled
0  narrative generation ended with status=timeout
19 narrative session cleanup failed

DAY 2026-04-27
0  managed dreaming cron could not be reconciled
19 narrative generation ended with status=timeout
19 narrative session cleanup failed

Source-level finding

In the installed bundle, dist/dreaming-narrative-*.js contains:

const NARRATIVE_TIMEOUT_MS = 15e3;
...
const result = await params.subagent.waitForRun({
  runId,
  timeoutMs: NARRATIVE_TIMEOUT_MS
});
if (result.status !== "ok") {
  params.logger.warn(`memory-core: narrative generation ended with status=${result.status} for ${params.data.phase} phase.`);
  return;
}
...
finally {
  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)}`);
  }
}

In dist/dreaming-*.js, cron-triggered dreaming detaches narratives:

const detachNarratives = params.trigger === "cron";
...
if (params.detachNarratives) queueMicrotask(() => {
  generateAndAppendDreamNarrative(...).catch(() => void 0);
});

So the failure chain appears to be:

  1. Managed dreaming cron runs successfully.
  2. It launches detached narrative generation for light/rem/deep phases across workspaces.
  3. Narrative subagent waits only 15 seconds; some runs time out.
  4. The cleanup path calls subagent.deleteSession from a plugin/internal context that lacks operator.admin.
  5. Cleanup failures are logged as warnings, creating recurring noise.

Expected behavior

  • Dreaming narrative cleanup should be best-effort and should not warn repeatedly because an internal plugin caller lacks operator.admin.
  • Internal memory-core cleanup should either have the required scope, use a scoped runtime cleanup API, or downgrade known cleanup permission failures when the artifact is harmless.
  • The 15s narrative timeout should perhaps be configurable, or timeout logs should be less noisy if narrative generation is optional.

Impact

  • Memory promotion itself appears successful (dreaming promotion complete ... failed=0).
  • The problem creates repeated warning noise in gateway.err.log and makes health checks look worse than they are.
  • Potentially leaves narrative temp session metadata/transcripts until scrub/doctor cleanup handles them.

Suggested fix direction

  • Ensure memory-core internal narrative cleanup can delete its own temporary dreaming-narrative-* sessions without requiring an external operator.admin gateway client scope; or
  • Make deleteSession best-effort with explicit handling for missing scope: operator.admin in this plugin path; and
  • Consider making NARRATIVE_TIMEOUT_MS configurable or increasing it for cron/detached narrative generation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions