fix: remove duplicate system prompt in CleanContextRunner#84
Conversation
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.
|
Reviewer triage notes: CI blocker:
Compatibility blocker / decision needed:
Suggested resolution: either bump the declared minimum OpenClaw version to the version where |
|
I opened #86 as a compatibility-preserving alternative to this PR. It keeps |
|
感谢发现 system prompt 重复注入的问题!我们会评估最佳方案后跟进,感谢关注! |
|
Thank you for your attention and handling! Going forward, please submit such fixes via Pull Requests (PRs) for merging, instead of pushing branches directly to the main repository. This will help us with code review and version tracking. |
The CleanContextRunner was passing the system prompt via two paths simultaneously:
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.
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.
Problem
CleanContextRunnerpasses the system prompt torunEmbeddedPiAgentvia two paths simultaneously:config.agents.defaults.systemPromptOverride— the primary path, which completely replaces the default agent system promptextraSystemPromptparameter — a legacy fallback intended for older versions of openclawOn current versions of openclaw, both paths are active. In
openclaw/src/agents/pi-embedded-runner/run/attempt-system-prompt.ts,buildAttemptSystemPromptprocesses them as follows:When
systemPromptOverrideTextis present,appendRuntimeExtraSystemPromptappendsextraSystemPromptafter it. Since both contain the same content (e.g.EXTRACT_MEMORIES_SYSTEM_PROMPT), the final system message becomes:This affects all modules that use
CleanContextRunner:l1-extractor.ts)l1-dedup.ts)scene-extractor.ts)persona-generator.ts)Impact
Fix
Remove the
extraSystemPromptparameter from therunEmbeddedPiAgentcall inCleanContextRunner.run(). The system prompt is already fully handled viaconfig.agents.defaults.systemPromptOverride.After this fix, on openclaw < 2026.4.7, users should enable the LLM configuration item for the plugin, so as to use the StandaloneLLMRunner instead of CleanContextRunner.
Changes
src/utils/clean-context-runner.ts: RemoveeffectiveSystemPromptvariable andextraSystemPromptparameter passed torunEmbeddedPiAgent