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 <vincentkoc@ieee.org>
This commit is contained in:
Masato Hoshino
2026-06-28 00:34:38 +09:00
committed by GitHub
parent cb4244fe15
commit ddedf13190
2 changed files with 24 additions and 1 deletions

View File

@@ -15,3 +15,21 @@ describe("irc outbound chunking", () => {
expect(ircOutboundBaseAdapter.textChunkLimit).toBe(350);
});
});
describe("irc outbound sanitizeText", () => {
afterEach(() => {
clearIrcRuntime();
});
it("strips internal tool-trace banners before outbound delivery", () => {
const text = "Done.\n⚠ 🛠️ `search repos (agent)` failed";
expect(ircOutboundBaseAdapter.sanitizeText({ text })).toBe("Done.");
});
it("preserves ordinary assistant prose while sanitizing", () => {
const text = "The pipeline has 3 open deals.";
expect(ircOutboundBaseAdapter.sanitizeText({ text })).toBe(text);
});
});

View File

@@ -1,5 +1,6 @@
// Irc plugin module implements outbound base behavior.
import { sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
import { chunkTextForOutbound } from "./channel-api.js";
export const ircOutboundBaseAdapter = {
@@ -7,5 +8,9 @@ export const ircOutboundBaseAdapter = {
chunker: chunkTextForOutbound,
chunkerMode: "markdown" as const,
textChunkLimit: 350,
sanitizeText: ({ text }: { text: string }) => sanitizeForPlainText(text),
// IRC's plain-text pass does not remove assistant scaffolding. Run the
// canonical delivery sanitizer first so internal tool traces are dropped
// before channel formatting.
sanitizeText: ({ text }: { text: string }) =>
sanitizeForPlainText(sanitizeAssistantVisibleText(text)),
};