Summary
The CLI turn compaction lifecycle resolves the active context engine without first calling ensureContextEnginesInitialized(), so the bundled legacy engine is missing from the registry when this code path runs in a worker that wasn't bootstrapped via pi-embedded or the subagent spawn path.
The visible symptom is the dreaming narrative diary subagent: every nightly sweep silently fails to append to DREAMS.md, and openclaw memory status --deep reports Dreaming artifacts: diary absent indefinitely. The underlying log line is buried at log.warn level:
CLI transcript persistence failed for agent:main:dreaming-narrative-light-<hash>: Context engine "legacy" is not registered. Available engines: (none)
This is a follow-up to #76576 / PR #76636: same class of "engine not registered yet" bug, different code path. #76636 fixed it for the gateway startup load plan when a custom plugins.slots.contextEngine plugin was selected. The CLI compaction lifecycle never got the same treatment, and it breaks even with the default (legacy) slot.
Repro
- Install
[email protected].
- Use Claude CLI auth (
provider: claude-cli) — i.e. the OpenClaw anthropic:claude-cli auth profile, not a direct ANTHROPIC_API_KEY. This is the trigger for the CLI runner path at agent-command-CYAAR35V.js:883 (result.meta.executionTrace?.runner === "cli").
- Enable dreaming with no other custom config:
{
plugins: {
entries: {
"memory-core": { config: { dreaming: { enabled: true } } }
}
}
}
- Leave
plugins.slots.contextEngine unset (= bundled legacy default).
- Let the nightly sweep run.
Expected: DREAMS.md gets a diary entry each night. memory status --deep shows diary present.
Actual: Light/REM/deep phase reports appear daily under memory/dreaming/{light,rem,deep}/YYYY-MM-DD.md, but DREAMS.md is never written. memory status --deep shows diary absent. The warning above appears in logs once per sweep.
The grounded backfill lane (openclaw memory rem-backfill --path …) bypasses the broken code path entirely and successfully writes DREAMS.md, which confirms the failure is specifically in the diary subagent's transcript-persistence path, not in dreaming generally.
Root cause
dist/cli-compaction-DUTxpPGR.js:95 defines runCliTurnCompactionLifecycle, which at line 99 calls:
const contextEngine = await cliCompactionDeps.resolveContextEngine(params.cfg);
without any prior call to ensureContextEnginesInitialized() (which is what registers the bundled legacy engine, per dist/init-CtKlTCAI.js:37–56).
The other entry points that resolve the engine all do guard the registry:
- Main runtime:
pi-embedded-Bcz04p2i.js:85 and :2063
- Subagent spawn:
subagent-spawn-CZA9_Uwl.js:464
- Subagent registry:
subagent-registry-BTDmugmA.js:1366
So the failure is path-specific: the dreaming diary subagent (and any other subagent whose transcript-finalize step runs the CLI compaction lifecycle in a fresh worker) hits an empty registry. resolveContextEngine's default-engine branch (registry-CxcGD4Pv.js:253) then throws, and agent-command-CYAAR35V.js:918 swallows it as a log.warn — which is also why this has been silently broken for users on Claude-CLI auth with dreaming enabled.
Suggested fix
Add the same idempotent guard at the top of runCliTurnCompactionLifecycle in src/agents/command/cli-compaction.ts, before the resolveContextEngine call:
ensureContextEnginesInitialized();
const contextEngine = await cliCompactionDeps.resolveContextEngine(params.cfg);
ensureContextEnginesInitialized is already idempotent (guarded by an initialized flag), so adding this call is safe even on hot paths. Same shape as the existing guards in pi-embedded and the subagent spawn module.
Optional adjacent cleanup: bump the swallowed warning at agent-command-CYAAR35V.js:918 to also note when the cause is a missing engine registration — silent failure is the reason this took a while to notice.
Environment
[email protected]
- macOS (darwin 25.5.0)
- Auth:
anthropic:claude-cli (provider claude-cli)
plugins.slots.contextEngine: unset (default legacy)
- Dreaming:
enabled: true, otherwise default config
Summary
The CLI turn compaction lifecycle resolves the active context engine without first calling
ensureContextEnginesInitialized(), so the bundledlegacyengine is missing from the registry when this code path runs in a worker that wasn't bootstrapped viapi-embeddedor the subagent spawn path.The visible symptom is the dreaming narrative diary subagent: every nightly sweep silently fails to append to
DREAMS.md, andopenclaw memory status --deepreportsDreaming artifacts: diary absentindefinitely. The underlying log line is buried atlog.warnlevel:This is a follow-up to #76576 / PR #76636: same class of "engine not registered yet" bug, different code path. #76636 fixed it for the gateway startup load plan when a custom
plugins.slots.contextEngineplugin was selected. The CLI compaction lifecycle never got the same treatment, and it breaks even with the default (legacy) slot.Repro
[email protected].provider: claude-cli) — i.e. the OpenClawanthropic:claude-cliauth profile, not a directANTHROPIC_API_KEY. This is the trigger for the CLI runner path atagent-command-CYAAR35V.js:883(result.meta.executionTrace?.runner === "cli").plugins.slots.contextEngineunset (= bundledlegacydefault).Expected:
DREAMS.mdgets a diary entry each night.memory status --deepshowsdiary present.Actual: Light/REM/deep phase reports appear daily under
memory/dreaming/{light,rem,deep}/YYYY-MM-DD.md, butDREAMS.mdis never written.memory status --deepshowsdiary absent. The warning above appears in logs once per sweep.The grounded backfill lane (
openclaw memory rem-backfill --path …) bypasses the broken code path entirely and successfully writesDREAMS.md, which confirms the failure is specifically in the diary subagent's transcript-persistence path, not in dreaming generally.Root cause
dist/cli-compaction-DUTxpPGR.js:95definesrunCliTurnCompactionLifecycle, which at line 99 calls:without any prior call to
ensureContextEnginesInitialized()(which is what registers the bundledlegacyengine, perdist/init-CtKlTCAI.js:37–56).The other entry points that resolve the engine all do guard the registry:
pi-embedded-Bcz04p2i.js:85and:2063subagent-spawn-CZA9_Uwl.js:464subagent-registry-BTDmugmA.js:1366So the failure is path-specific: the dreaming diary subagent (and any other subagent whose transcript-finalize step runs the CLI compaction lifecycle in a fresh worker) hits an empty registry.
resolveContextEngine's default-engine branch (registry-CxcGD4Pv.js:253) then throws, andagent-command-CYAAR35V.js:918swallows it as alog.warn— which is also why this has been silently broken for users on Claude-CLI auth with dreaming enabled.Suggested fix
Add the same idempotent guard at the top of
runCliTurnCompactionLifecycleinsrc/agents/command/cli-compaction.ts, before theresolveContextEnginecall:ensureContextEnginesInitializedis already idempotent (guarded by aninitializedflag), so adding this call is safe even on hot paths. Same shape as the existing guards inpi-embeddedand the subagent spawn module.Optional adjacent cleanup: bump the swallowed warning at
agent-command-CYAAR35V.js:918to also note when the cause is a missing engine registration — silent failure is the reason this took a while to notice.Environment
[email protected]anthropic:claude-cli(providerclaude-cli)plugins.slots.contextEngine: unset (defaultlegacy)enabled: true, otherwise default config