From 05cc036f6d9bb293dbb779cb22fbd1989584a0f5 Mon Sep 17 00:00:00 2001 From: Evandro Fonseca Junior Date: Sat, 4 Apr 2026 02:48:09 -0300 Subject: [PATCH] fix(ui): prevent system prompt echo from bleeding into visible text for agentic mode prompts Added the 'You are a helpful local ai assistant' pattern to the hasKnownPromptEcho matcher so the UI correctly strips transcript bleed before displaying or saving it to SQLite. --- tauri-app/src/lib/chat.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tauri-app/src/lib/chat.ts b/tauri-app/src/lib/chat.ts index 9f254a5..da31dea 100644 --- a/tauri-app/src/lib/chat.ts +++ b/tauri-app/src/lib/chat.ts @@ -60,9 +60,11 @@ function stripQwenChatTemplateTokens(text: string): string { function hasKnownPromptEcho(text: string): boolean { return /^\s*you are a helpful ai assistant\.?/i.test(text) + || /^\s*you are a helpful local ai assistant\.?/i.test(text) || /^\s*you will be tested with prior context/i.test(text) || /^\s*you are a precise coding assistant running locally\.?/i.test(text) - || /^\s*(?:#{1,6}\s*)?(?:System|Developer)\s*:\s*you are a precise coding assistant running locally\.?/i.test(text); + || /^\s*(?:#{1,6}\s*)?(?:System|Developer)\s*:\s*you are a precise coding assistant running locally\.?/i.test(text) + || /^\s*(?:#{1,6}\s*)?(?:System|Developer)\s*:\s*you are a helpful local ai assistant/i.test(text); } function stripLeadingFencedTranscriptLeakage(text: string): string { @@ -106,10 +108,12 @@ export function stripPromptEchoAndTranscriptLeakage(text: string): string { // Known leaked system-prompt openings: drop them entirely. if (/^\s*you are a helpful ai assistant\.?/i.test(trimmed)) return ""; + if (/^\s*you are a helpful local ai assistant\.?/i.test(trimmed)) return ""; if (/^\s*you will be tested with prior context/i.test(trimmed)) return ""; if (/^\s*you are a precise coding assistant running locally\.?/i.test(trimmed)) return ""; if (/^\s*(?:#{1,6}\s*)?(?:System|Developer)\s*:\s*you are a precise coding assistant running locally\.?/i.test(trimmed)) return ""; if (/^\s*(?:#{1,6}\s*)?(?:System|Developer)\s*:\s*you are a precise coding assistant running locally\.?/i.test(fenceStripped)) return ""; + if (/^\s*(?:#{1,6}\s*)?(?:System|Developer)\s*:\s*you are a helpful local ai assistant/i.test(trimmed)) return ""; return withoutLeadingLeakedFence; }