Skip to content

Commit 43672fd

Browse files
committed
fix(plugin): sanitize prompt fallback in before_prompt_build to prevent query pollution
The prompt fallback path bypassed sanitizeUserTextForCapture, allowing Sender metadata blocks and timestamps to be sent as search queries to the OpenViking API, causing irrelevant memories to rank highly. Made-with: Cursor
1 parent 4e8951d commit 43672fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/openclaw-plugin/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
compileSessionPatterns,
1212
isTranscriptLikeIngest,
1313
extractLatestUserText,
14+
sanitizeUserTextForCapture,
1415
shouldBypassSession,
1516
} from "./text-utils.js";
1617
import {
@@ -884,7 +885,7 @@ const contextEnginePlugin = {
884885
const eventObj = (event ?? {}) as { messages?: unknown[]; prompt?: string };
885886
const queryText =
886887
extractLatestUserText(eventObj.messages) ||
887-
(typeof eventObj.prompt === "string" ? eventObj.prompt.trim() : "");
888+
(typeof eventObj.prompt === "string" ? sanitizeUserTextForCapture(eventObj.prompt) : "");
888889
if (!queryText) {
889890
return;
890891
}

0 commit comments

Comments
 (0)