fix(telegram): sanitize outbound tool traces · openclaw/openclaw@434d752
mushuiyu886
·
2026-06-24
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@
|
2 | 2 | import type { OutboundDeliveryFormattingOptions } from "openclaw/plugin-sdk/channel-outbound"; |
3 | 3 | import { |
4 | 4 | resolveOutboundSendDep, |
| 5 | +sanitizeForPlainText, |
5 | 6 | type OutboundSendDeps, |
6 | 7 | } from "openclaw/plugin-sdk/channel-outbound"; |
7 | 8 | import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk/channel-send-result"; |
@@ -19,6 +20,7 @@ import {
|
19 | 20 | sendPayloadMediaSequenceOrFallback, |
20 | 21 | } from "openclaw/plugin-sdk/reply-payload"; |
21 | 22 | import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime"; |
| 23 | +import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking"; |
22 | 24 | import type { TelegramInlineButtons } from "./button-types.js"; |
23 | 25 | import { resolveTelegramInlineButtons } from "./button-types.js"; |
24 | 26 | import { splitTelegramHtmlChunks } from "./format.js"; |
@@ -198,6 +200,7 @@ export function createTelegramOutboundAdapter(
|
198 | 200 | chunkerMode: "markdown", |
199 | 201 | extractMarkdownImages: true, |
200 | 202 | textChunkLimit: TELEGRAM_TEXT_CHUNK_LIMIT, |
| 203 | +sanitizeText: ({ text }) => sanitizeForPlainText(sanitizeAssistantVisibleText(text)), |
201 | 204 | shouldSuppressLocalPayloadPrompt: options.shouldSuppressLocalPayloadPrompt, |
202 | 205 | beforeDeliverPayload: options.beforeDeliverPayload, |
203 | 206 | shouldTreatDeliveredTextAsVisible: options.shouldTreatDeliveredTextAsVisible, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -29,10 +29,23 @@ describe("telegramPlugin outbound", () => {
|
29 | 29 | expect(telegramOutbound.presentationCapabilities?.limits?.text?.markdownDialect).toBe( |
30 | 30 | "markdown", |
31 | 31 | ); |
32 | | -expect(telegramOutbound.sanitizeText).toBeUndefined(); |
33 | 32 | expect(telegramOutbound.pollMaxOptions).toBe(10); |
34 | 33 | }); |
35 | 34 | |
| 35 | +it("strips assistant-visible tool traces before outbound delivery", () => { |
| 36 | +clearTelegramRuntime(); |
| 37 | +const text = 'Done.\n⚠️ 🛠️ `search "Pipeline" in ~/.openclaw/workspace-* (agent)` failed'; |
| 38 | + |
| 39 | +expect(telegramOutbound.sanitizeText?.({ text })).toBe("Done."); |
| 40 | +}); |
| 41 | + |
| 42 | +it("preserves ordinary outbound text while sanitizing", () => { |
| 43 | +clearTelegramRuntime(); |
| 44 | +const text = "The pipeline has 3 deals."; |
| 45 | + |
| 46 | +expect(telegramOutbound.sanitizeText?.({ text })).toBe(text); |
| 47 | +}); |
| 48 | + |
36 | 49 | it("preserves explicit HTML parse mode before chunking", () => { |
37 | 50 | clearTelegramRuntime(); |
38 | 51 | const text = "<b>hi</b>"; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。