Skip to content

[Bug]: memory-core: narrative session cleanup fails with "missing scope: operator.admin" #68074

Description

@zhxind

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

The memory-core plugin's dreaming feature generates a warning log every time it runs, stating memory-core: narrative session cleanup failed for light/rem phase: missing scope: operator.admin. This occurs because the subagent.deleteSession() method called during narrative session cleanup requires operator.admin permission, but the dreaming cron job runs in the main session which does not have this scope.

Steps to reproduce

Enable memory-core plugin with dreaming feature:

"plugins": {
  "entries": {
    "memory-core": {
      "enabled": true,
      "config": {
        "dreaming": {
          "enabled": true,
          "frequency": "0 */4 * * *"
        }
      }
    }
  }
}
Wait for the dreaming cron to trigger (runs every 4 hours by default)
Check openclaw logs and observe the warning after each dreaming cycle

### Expected behavior

The narrative session cleanup should either:

Succeed without errors when permissions are sufficient, or
Fail silently without a warning log when operator.admin is missing, since cleanup is best-effort and the core dreaming/promotion functionality still works

### Actual behavior

The following warning appears in logs after every dreaming cycle:

Copy
warn plugins {"subsystem":"plugins"} memory-core: narrative session cleanup failed for light phase: missing scope: operator.admin
warn plugins {"subsystem":"plugins"} memory-core: narrative session cleanup failed for rem phase: missing scope: operator.admin
The core dreaming/promotion functionality works correctly, but orphaned narrative subagent sessions may accumulate over time.

### OpenClaw version

2026.4.15

### Operating system

Ubuntu 24.04.4 LTS 

### Install method

pnpm

### Model

minimax/MiniMax-M2.7

### Provider / routing chain

Embedded agent runtime → memory-core plugin → dreaming-narrative.ts

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence

```shell
2026-04-17T16:00:56.436+08:00 warn plugins {"subsystem":"plugins"} memory-core: narrative session cleanup failed for light phase: missing scope: operator.admin
2026-04-17T16:01:29.066+08:00 warn plugins {"subsystem":"plugins"} memory-core: narrative session cleanup failed for rem phase: missing scope: operator.admin

Impact and severity

Root cause traced to:

extensions/memory-core/src/dreaming-narrative.ts:933 — calls subagent.deleteSession()
extensions/memory-core/src/dreaming.ts:146 — managed dreaming cron hardcoded with sessionTarget: "main"
Main session lacks operator.admin scope, causing all cleanup attempts to fail
Related code:

Copy
// dreaming.ts:146 — hardcoded sessionTarget
function buildManagedDreamingCronJob(config: ShortTermPromotionDreamingConfig): ManagedCronJobCreate {
return {
sessionTarget: "main", // ← cannot be configured, main session has no operator.admin
wakeMode: "now",
payload: { kind: "systemEvent", text: DREAMING_SYSTEM_EVENT_TEXT },
};
}

// dreaming-narrative.ts:933 — permission-gated operation
try {
await params.subagent.deleteSession({ sessionKey });
} catch (cleanupErr) {
params.logger.warn(
memory-core: narrative session cleanup failed for ${params.data.phase} phase: ${formatErrorMessage(cleanupErr)},
);
}
Suggested fix: When deleteSession() fails due to missing operator.admin, the error should be caught and treated as a non-fatal best-effort cleanup (log at debug level instead of warn), since narrative cleanup failures do not impact the core memory promotion functionality.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregressionBehavior that previously worked and now fails

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions