Skip to content

Commit e04020a

Browse files
committed
fix(slack): sanitize internal tool-trace lines from outbound text
Wrap the slack outbound sanitizeText hook with sanitizeAssistantVisibleText so assistant internal tool-trace scaffolding is stripped before delivery, matching the sibling channel fixes under #90684 (Telegram #95774, Google Chat #95084, IRC #97214).
1 parent c6ade83 commit e04020a

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

extensions/slack/src/channel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
normalizeLowercaseStringOrEmpty,
3131
normalizeOptionalString,
3232
} from "openclaw/plugin-sdk/string-coerce-runtime";
33+
import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
3334
import {
3435
resolveDefaultSlackAccountId,
3536
resolveSlackAccount,
@@ -423,6 +424,7 @@ const slackChannelOutbound: ChannelOutboundAdapter = {
423424
deliveryMode: "direct",
424425
chunker: null,
425426
textChunkLimit: SLACK_TEXT_LIMIT,
427+
sanitizeText: ({ text }) => sanitizeAssistantVisibleText(text),
426428
normalizePayload: ({ payload, cfg, accountId }) =>
427429
isSlackInteractiveRepliesEnabled({ cfg, accountId })
428430
? compileSlackInteractiveReplies(payload)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Slack outbound must strip assistant internal tool-trace scaffolding, matching
2+
// the sibling channel fixes tracked under #90684 (Telegram #95774 / Google Chat
3+
// #95084 / IRC #97214). sanitizeAssistantVisibleText keeps mrkdwn formatting.
4+
import { describe, expect, it } from "vitest";
5+
import { slackPlugin } from "./channel.js";
6+
7+
describe("slack outbound sanitizeText", () => {
8+
it("strips internal tool-trace banners before outbound delivery", () => {
9+
const text = "Done.\n⚠️ 🛠️ `search repos (agent)` failed";
10+
11+
expect(slackPlugin.outbound?.sanitizeText?.({ text, payload: { text } })).toBe("Done.");
12+
});
13+
14+
it("preserves ordinary assistant prose while sanitizing", () => {
15+
const text = "The pipeline has 3 open deals.";
16+
17+
expect(slackPlugin.outbound?.sanitizeText?.({ text, payload: { text } })).toBe(text);
18+
});
19+
});

0 commit comments

Comments
 (0)