Skip to content

Commit ddedf13

Browse files
fix(irc): sanitize internal tool-trace lines from outbound text (#97214)
* fix(irc): sanitize internal tool-trace lines from outbound text * fix(irc): sanitize internal tool-trace lines from outbound text --------- Co-authored-by: Vincent Koc <[email protected]>
1 parent cb4244f commit ddedf13

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

extensions/irc/src/channel.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,21 @@ describe("irc outbound chunking", () => {
1515
expect(ircOutboundBaseAdapter.textChunkLimit).toBe(350);
1616
});
1717
});
18+
19+
describe("irc outbound sanitizeText", () => {
20+
afterEach(() => {
21+
clearIrcRuntime();
22+
});
23+
24+
it("strips internal tool-trace banners before outbound delivery", () => {
25+
const text = "Done.\n⚠️ 🛠️ `search repos (agent)` failed";
26+
27+
expect(ircOutboundBaseAdapter.sanitizeText({ text })).toBe("Done.");
28+
});
29+
30+
it("preserves ordinary assistant prose while sanitizing", () => {
31+
const text = "The pipeline has 3 open deals.";
32+
33+
expect(ircOutboundBaseAdapter.sanitizeText({ text })).toBe(text);
34+
});
35+
});
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// Irc plugin module implements outbound base behavior.
22
import { sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
3+
import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
34
import { chunkTextForOutbound } from "./channel-api.js";
45

56
export const ircOutboundBaseAdapter = {
67
deliveryMode: "direct" as const,
78
chunker: chunkTextForOutbound,
89
chunkerMode: "markdown" as const,
910
textChunkLimit: 350,
10-
sanitizeText: ({ text }: { text: string }) => sanitizeForPlainText(text),
11+
// IRC's plain-text pass does not remove assistant scaffolding. Run the
12+
// canonical delivery sanitizer first so internal tool traces are dropped
13+
// before channel formatting.
14+
sanitizeText: ({ text }: { text: string }) =>
15+
sanitizeForPlainText(sanitizeAssistantVisibleText(text)),
1116
};

0 commit comments

Comments
 (0)