From d961d8ae201bac3eb7a45120213dff6eee81c04a Mon Sep 17 00:00:00 2001 From: kagura-agent Date: Thu, 9 Apr 2026 22:26:16 +0800 Subject: [PATCH] fix(openclaw-plugin): read allowPromptInjection from plugin config (fixes #1383 bug 3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, allowPromptInjection was only read from the framework's hooks config (plugins.entries..hooks.allowPromptInjection). Users who set it in the plugin's own config block had no effect. Now reads from both locations — setting allowPromptInjection: false in either the plugin config or the hooks config will disable auto-recall. Also adds the property to the MemosLocalConfig type and configSchema. --- apps/memos-local-openclaw/index.ts | 6 +++++- apps/memos-local-openclaw/openclaw.plugin.json | 4 ++++ apps/memos-local-openclaw/src/types.ts | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/memos-local-openclaw/index.ts b/apps/memos-local-openclaw/index.ts index 5e224519..305f4690 100644 --- a/apps/memos-local-openclaw/index.ts +++ b/apps/memos-local-openclaw/index.ts @@ -392,8 +392,12 @@ const memosLocalPlugin = { // ─── Check allowPromptInjection policy ─── // When allowPromptInjection=false, the prompt mutation fields (such as prependContext) in the hook return value // will be stripped by the framework. Skip auto-recall to avoid unnecessary LLM/embedding calls. + // Reads from both the framework hook config (plugins.entries..hooks.allowPromptInjection) + // and the plugin's own config (allowPromptInjection), so users can set it in either place. const pluginEntry = (api.config as any)?.plugins?.entries?.[api.id]; - const allowPromptInjection = pluginEntry?.hooks?.allowPromptInjection !== false; + const allowPromptInjection = + pluginEntry?.hooks?.allowPromptInjection !== false && + ctx.config.allowPromptInjection !== false; if (!allowPromptInjection) { api.logger.info("memos-local: allowPromptInjection=false, auto-recall disabled"); } diff --git a/apps/memos-local-openclaw/openclaw.plugin.json b/apps/memos-local-openclaw/openclaw.plugin.json index bb828c19..bf7a6202 100644 --- a/apps/memos-local-openclaw/openclaw.plugin.json +++ b/apps/memos-local-openclaw/openclaw.plugin.json @@ -16,6 +16,10 @@ "viewerPort": { "type": "number", "description": "Memory Viewer HTTP port (default 18799)" + }, + "allowPromptInjection": { + "type": "boolean", + "description": "Set to false to disable automatic memory recall injection into prompts (default true)" } } }, diff --git a/apps/memos-local-openclaw/src/types.ts b/apps/memos-local-openclaw/src/types.ts index cb08eb1c..a8ef7c83 100644 --- a/apps/memos-local-openclaw/src/types.ts +++ b/apps/memos-local-openclaw/src/types.ts @@ -324,6 +324,8 @@ export interface MemosLocalConfig { sharing?: SharingConfig; /** Hours of inactivity after which an active task is automatically finalized. 0 = disabled. Default 4. */ taskAutoFinalizeHours?: number; + /** Set to false to disable automatic memory recall injection into prompts (default true). */ + allowPromptInjection?: boolean; } // ─── Defaults ───