diff --git a/src/memory/prompt-section.ts b/src/memory/prompt-section.ts index 322d040312a..e1fe0470b8d 100644 --- a/src/memory/prompt-section.ts +++ b/src/memory/prompt-section.ts @@ -23,7 +23,10 @@ export function buildMemoryPromptSection(params: { return _builder?.(params) ?? []; } -/** Reset state (for tests). */ -export function _resetMemoryPromptSection(): void { +/** Clear the registered builder (called on plugin reload and in tests). */ +export function clearMemoryPromptSection(): void { _builder = undefined; } + +/** @deprecated Use {@link clearMemoryPromptSection}. */ +export const _resetMemoryPromptSection = clearMemoryPromptSection; diff --git a/src/plugins/loader.ts b/src/plugins/loader.ts index 03a1b0810ff..b4b9e8edb1e 100644 --- a/src/plugins/loader.ts +++ b/src/plugins/loader.ts @@ -10,6 +10,7 @@ import type { GatewayRequestHandler } from "../gateway/server-methods/types.js"; import { openBoundaryFileSync } from "../infra/boundary-file-read.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { resolveUserPath } from "../utils.js"; +import { clearMemoryPromptSection } from "../memory/prompt-section.js"; import { inspectBundleMcpRuntimeSupport } from "./bundle-mcp.js"; import { clearPluginCommands } from "./commands.js"; import { @@ -113,6 +114,7 @@ const LAZY_RUNTIME_REFLECTION_KEYS = [ export function clearPluginLoaderCache(): void { registryCache.clear(); openAllowlistWarningCache.clear(); + clearMemoryPromptSection(); } const defaultLogger = () => createSubsystemLogger("plugins"); @@ -739,11 +741,12 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi } } - // Clear previously registered plugin commands before reloading. + // Clear previously registered plugin state before reloading. // Skip for non-activating (snapshot) loads to avoid wiping commands from other plugins. if (shouldActivate) { clearPluginCommands(); clearPluginInteractiveHandlers(); + clearMemoryPromptSection(); } // Lazy: avoid creating the Jiti loader when all plugins are disabled (common in unit tests).