Skip to content

Commit dce31a1

Browse files
fix(mattermost): strip internal tool-trace banners from outbound text
Co-authored-by: Cursor <[email protected]>
1 parent eb87566 commit dce31a1

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

extensions/mattermost/src/channel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
createDefaultChannelRuntimeState,
3434
} from "openclaw/plugin-sdk/status-helpers";
3535
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
36+
import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
3637
import { mattermostApprovalAuth } from "./approval-auth.js";
3738
import {
3839
chunkTextForOutbound,
@@ -627,6 +628,7 @@ const mattermostOutbound: ChannelOutboundAdapter = {
627628
chunker: chunkTextForOutbound,
628629
chunkerMode: "markdown",
629630
textChunkLimit: 4000,
631+
sanitizeText: ({ text }) => sanitizeAssistantVisibleText(text),
630632
deliveryCapabilities: {
631633
durableFinal: {
632634
text: true,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Mattermost outbound must strip assistant internal tool-trace scaffolding,
2+
// matching the sibling channel fixes tracked under #90684 (Slack / Telegram /
3+
// Google Chat / IRC / SMS). sanitizeAssistantVisibleText keeps Markdown prose.
4+
import { describe, expect, it } from "vitest";
5+
import { mattermostPlugin } from "./channel.js";
6+
7+
describe("mattermost outbound sanitizeText", () => {
8+
it("strips internal tool-trace banners before outbound delivery", () => {
9+
const text = "Done.\n⚠️ 🛠️ `search repos (agent)` failed";
10+
11+
expect(mattermostPlugin.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(mattermostPlugin.outbound?.sanitizeText?.({ text, payload: { text } })).toBe(text);
18+
});
19+
});

0 commit comments

Comments
 (0)