fix(googlechat): sanitize internal tool-trace lines from outbound tex… · openclaw/openclaw@696c624
jailbirt
·
2026-06-22
·
via Recent Commits to openclaw:main
File tree
extensions/googlechat/src
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,7 @@ import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
|
23 | 23 | import type { OutboundMediaLoadOptions } from "openclaw/plugin-sdk/outbound-media"; |
24 | 24 | import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime"; |
25 | 25 | import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime"; |
| 26 | +import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking"; |
26 | 27 | import { shouldSuppressGoogleChatManualExecApprovalFollowupPayload } from "./approval-card-actions.js"; |
27 | 28 | import { formatGoogleChatAllowFromEntry } from "./channel-base.js"; |
28 | 29 | import { |
@@ -194,7 +195,11 @@ export const googlechatOutboundAdapter = {
|
194 | 195 | chunker: chunkTextForOutbound, |
195 | 196 | chunkerMode: "markdown" as const, |
196 | 197 | textChunkLimit: 4000, |
197 | | -sanitizeText: ({ text }: { text: string }) => sanitizeForPlainText(text), |
| 198 | +// Google Chat's plain-text pass does not remove assistant scaffolding. |
| 199 | +// Run the canonical delivery sanitizer first so internal tool traces are |
| 200 | +// dropped before channel formatting. |
| 201 | +sanitizeText: ({ text }: { text: string }) => |
| 202 | +sanitizeForPlainText(sanitizeAssistantVisibleText(text)), |
198 | 203 | normalizePayload: ({ payload }: { payload: ReplyPayload }) => |
199 | 204 | shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload) ? null : payload, |
200 | 205 | resolveTarget: ({ to }: { to?: string }) => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -843,3 +843,21 @@ describe("googlechatPlugin security", () => {
|
843 | 843 | ); |
844 | 844 | }); |
845 | 845 | }); |
| 846 | + |
| 847 | +describe("googlechatPlugin outbound sanitizeText", () => { |
| 848 | +const sanitizeText = googlechatOutboundAdapter.base.sanitizeText; |
| 849 | + |
| 850 | +it("strips internal tool-trace failure banners from outbound text (#90684)", () => { |
| 851 | +const text = |
| 852 | +"Visible answer.\n" + "⚠️ 🛠️ `run openclaw definitely-not-a-real-subcommand (agent)` failed"; |
| 853 | +const out = sanitizeText({ text }); |
| 854 | +expect(out).toBe("Visible answer."); |
| 855 | +expect(out).not.toContain("failed"); |
| 856 | +expect(out).not.toContain("🛠️"); |
| 857 | +}); |
| 858 | + |
| 859 | +it("preserves ordinary assistant prose untouched", () => { |
| 860 | +const text = "El pipeline tiene 3 deals abiertos por USD 12.000."; |
| 861 | +expect(sanitizeText({ text })).toBe(text); |
| 862 | +}); |
| 863 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。