From 7f5789575e0725b87330bd22296eb8987e46e545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mara=20=F0=9F=8C=BF?= Date: Sat, 25 Apr 2026 23:10:31 +0200 Subject: [PATCH] fix(memory-wiki): skip bridge pruning when memory-core is not loaded (#71764) When memory-core plugin is not registered (e.g. CLI context), listActiveMemoryPublicArtifacts returns an empty array. The previous code would then call pruneImportedSourceEntries with an empty activeKeys Set, which removes ALL bridge-imported entries. Now checks getMemoryCapabilityRegistration() instead of relying on artifact count as a proxy, correctly distinguishing between 'plugin not loaded' and 'plugin loaded with no artifacts'. Fixes #68373 --- extensions/memory-wiki/src/bridge.ts | 18 ++++++++++++------ src/memory-host-sdk/runtime-core.ts | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/extensions/memory-wiki/src/bridge.ts b/extensions/memory-wiki/src/bridge.ts index b81731ddcc9..88acb0815ce 100644 --- a/extensions/memory-wiki/src/bridge.ts +++ b/extensions/memory-wiki/src/bridge.ts @@ -2,6 +2,7 @@ import { createHash } from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; import { + getMemoryCapabilityRegistration, listActiveMemoryPublicArtifacts, type MemoryPluginPublicArtifact, } from "openclaw/plugin-sdk/memory-host-core"; @@ -248,12 +249,17 @@ export async function syncMemoryWikiBridgeSources(params: { } const workspaceCount = new Set(publicArtifacts.map((artifact) => artifact.workspaceDir)).size; - const removedCount = await pruneImportedSourceEntries({ - vaultRoot: params.config.vault.path, - group: "bridge", - activeKeys, - state, - }); + // Skip pruning when memory-core is not loaded (e.g. CLI context) to avoid + // removing all bridge-imported entries. See #68373. + const memoryCapability = getMemoryCapabilityRegistration(); + const removedCount = memoryCapability + ? await pruneImportedSourceEntries({ + vaultRoot: params.config.vault.path, + group: "bridge", + activeKeys, + state, + }) + : 0; await writeMemoryWikiSourceSyncState(params.config.vault.path, state); const importedCount = results.filter((result) => result.changed && result.created).length; const updatedCount = results.filter((result) => result.changed && !result.created).length; diff --git a/src/memory-host-sdk/runtime-core.ts b/src/memory-host-sdk/runtime-core.ts index 6a25fb11b80..c9e1b09fe11 100644 --- a/src/memory-host-sdk/runtime-core.ts +++ b/src/memory-host-sdk/runtime-core.ts @@ -20,6 +20,7 @@ export { emptyPluginConfigSchema } from "../plugins/config-schema.js"; export { buildMemoryPromptSection as buildActiveMemoryPromptSection, listActiveMemoryPublicArtifacts, + getMemoryCapabilityRegistration, } from "../plugins/memory-state.js"; export { parseAgentSessionKey } from "../routing/session-key.js"; export type { OpenClawConfig } from "../config/config.js";