From 5304583f01d6691b28cf8ca8f24d275332c470c1 Mon Sep 17 00:00:00 2001 From: radianli Date: Sun, 24 May 2026 20:48:51 +0800 Subject: [PATCH] fix: remove duplicate system prompt in CleanContextRunner The CleanContextRunner was passing the system prompt via two paths simultaneously: 1. config.agents.defaults.systemPromptOverride (primary) 2. extraSystemPrompt parameter (legacy fallback) On openclaw >= 2026.4.7, both paths are active, causing the same prompt to appear twice in the final system message, wasting tokens per LLM call. On openclaw < 2026.4.7, recommend enabling the LLM configuration item for the plugin, so as to use the StandaloneLLMRunner Remove the extraSystemPrompt parameter since systemPromptOverride fully handles the system prompt injection. This fixes the duplication for all downstream consumers: L1 extraction, L1 dedup, L2 scene extraction, and L3 persona generation. --- src/utils/clean-context-runner.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/utils/clean-context-runner.ts b/src/utils/clean-context-runner.ts index 868d787..50b49e0 100644 --- a/src/utils/clean-context-runner.ts +++ b/src/utils/clean-context-runner.ts @@ -439,12 +439,9 @@ export class CleanContextRunner { // Phase 2: Embedded agent run (LLM call + tool calls) const agentStartMs = Date.now(); - // extraSystemPrompt: fallback for openclaw < 2026.4.7 which does not support - // config.agents.defaults.systemPromptOverride. On newer versions the - // override takes precedence and this becomes a no-op append. - const effectiveSystemPrompt = - params.systemPrompt || - "You are a precise data extraction and generation assistant. Follow the user instructions exactly. Respond only with the requested output format."; + // System prompt is fully handled via config.agents.defaults.systemPromptOverride. + // Do NOT pass extraSystemPrompt — it would cause the same prompt to appear + // twice in the final system message (once from override, once appended). const result = await runEmbeddedPiAgent({ sessionId, sessionFile, @@ -460,7 +457,6 @@ export class CleanContextRunner { // Instead rely on cleanConfig.tools.allow to restrict the tool set // to a minimal read-only tool (when enableTools=false). disableTools: false, - extraSystemPrompt: effectiveSystemPrompt, streamParams: { maxTokens: params.maxTokens, },