diff --git a/extensions/qqbot/src/channel.message-adapter.test.ts b/extensions/qqbot/src/channel.message-adapter.test.ts index 27509445e579..f49f44dc88c2 100644 --- a/extensions/qqbot/src/channel.message-adapter.test.ts +++ b/extensions/qqbot/src/channel.message-adapter.test.ts @@ -4,6 +4,25 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts"; import { describe, expect, it, vi } from "vitest"; import { qqbotPlugin } from "./channel.js"; +describe("qqbot outbound sanitizeText", () => { + it("strips reasoning/thinking tags before delivery", () => { + const sanitize = qqbotPlugin.outbound?.sanitizeText; + expect(sanitize).toBeDefined(); + if (!sanitize) { + return; + } + + const input1 = "internal reasoningfinal answer"; + expect(sanitize({ text: input1, payload: { text: input1 } })).toBe("final answer"); + + const input2 = "step by stepresult"; + expect(sanitize({ text: input2, payload: { text: input2 } })).toBe("result"); + + const input3 = "plain text without tags"; + expect(sanitize({ text: input3, payload: { text: input3 } })).toBe("plain text without tags"); + }); +}); + const sendTextMock = vi.hoisted(() => vi.fn()); const sendMediaMock = vi.hoisted(() => vi.fn()); diff --git a/extensions/qqbot/src/channel.ts b/extensions/qqbot/src/channel.ts index 3df1652f6bae..b9442cbeb3de 100644 --- a/extensions/qqbot/src/channel.ts +++ b/extensions/qqbot/src/channel.ts @@ -8,6 +8,7 @@ import { } from "openclaw/plugin-sdk/channel-outbound"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts"; import type { ChannelPlugin } from "openclaw/plugin-sdk/core"; +import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking"; // Register the PlatformAdapter before any core/ module is used. import "./bridge/bootstrap.js"; import { getQQBotApprovalCapability } from "./bridge/approval/capability.js"; @@ -254,6 +255,7 @@ export const qqbotPlugin: ChannelPlugin = { chunker: (text, limit) => getQQBotRuntime().channel.text.chunkMarkdownText(text, limit), chunkerMode: "markdown", textChunkLimit: 5000, + sanitizeText: ({ text }) => sanitizeAssistantVisibleText(text), shouldSuppressLocalPayloadPrompt: ({ cfg, accountId, payload, hint }) => shouldSuppressLocalQQBotApprovalPrompt({ cfg,