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
This commit is contained in:
Mara 🌿
2026-04-25 23:10:31 +02:00
committed by GitHub
parent a1cb8d50ba
commit 7f5789575e
2 changed files with 13 additions and 6 deletions

View File

@@ -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;

View File

@@ -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";