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.
This commit is contained in:
1 parent
8afd2cbfed
commit
05cc036f6d
1 file changed
+5
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user