fix(imessage): only strip standalone role-turn markers, not prose end… · openclaw/openclaw@770b19f
ly-wang19
·
2026-06-25
·
via Recent Commits to openclaw:main
File tree
extensions/imessage/src/monitor
| Original file line number | Diff line number | Diff line change |
|---|
@@ -49,6 +49,15 @@ describe("sanitizeOutboundText", () => {
|
49 | 49 | expect(result).not.toMatch(/^assistant:$/m); |
50 | 50 | }); |
51 | 51 | |
| 52 | +it("preserves prose lines that merely end with 'user:'/'system:'", () => { |
| 53 | +expect(sanitizeOutboundText("Please send this reply to the user:")).toBe( |
| 54 | +"Please send this reply to the user:", |
| 55 | +); |
| 56 | +expect(sanitizeOutboundText("Here is a note for the system:")).toBe( |
| 57 | +"Here is a note for the system:", |
| 58 | +); |
| 59 | +}); |
| 60 | + |
52 | 61 | it("collapses excessive blank lines after stripping", () => { |
53 | 62 | const text = "Hello\n\n\n\n\nWorld"; |
54 | 63 | expect(sanitizeOutboundText(text)).toBe("Hello\n\nWorld"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -7,7 +7,9 @@ import { stripAssistantInternalScaffolding } from "openclaw/plugin-sdk/text-chun
|
7 | 7 | */ |
8 | 8 | const INTERNAL_SEPARATOR_RE = /(?:#\+){2,}#?/g; |
9 | 9 | const ASSISTANT_ROLE_MARKER_RE = /\bassistant\s+to\s*=\s*\w+/gi; |
10 | | -const ROLE_TURN_MARKER_RE = /\b(?:user|system|assistant)\s*:\s*$/gm; |
| 10 | +// Only a standalone role marker on its own line (a leaked turn boundary) — not |
| 11 | +// any line that merely ends with the word "user/system/assistant:" in prose. |
| 12 | +const ROLE_TURN_MARKER_RE = /^[ \t]*(?:user|system|assistant)\s*:\s*$/gm; |
11 | 13 | |
12 | 14 | /** |
13 | 15 | * Strip all assistant-internal scaffolding from outbound text before delivery. |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。