mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-20 17:34:59 +00:00
Build: sync main manifests and harden Matrix reasoning suppression
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
filterMessagingToolMediaDuplicates,
|
||||
shouldSuppressReasoningPayload,
|
||||
shouldSuppressMessagingToolReplies,
|
||||
} from "./reply-payloads.js";
|
||||
|
||||
@@ -154,3 +155,27 @@ describe("shouldSuppressMessagingToolReplies", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldSuppressReasoningPayload", () => {
|
||||
it("suppresses raw reasoning-prefix text even when isReasoning is absent", () => {
|
||||
expect(shouldSuppressReasoningPayload({ text: " Reasoning:\n_hidden_" })).toBe(true);
|
||||
});
|
||||
|
||||
it("suppresses thinking-tag-only text even when isReasoning is absent", () => {
|
||||
expect(shouldSuppressReasoningPayload({ text: "<think>hidden</think>" })).toBe(true);
|
||||
});
|
||||
|
||||
it("does not suppress text that merely mentions reasoning mid-message", () => {
|
||||
expect(
|
||||
shouldSuppressReasoningPayload({
|
||||
text: "Intro line\nReasoning: appears in content but is not a prefix",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("does not suppress messages that contain an answer outside thinking tags", () => {
|
||||
expect(shouldSuppressReasoningPayload({ text: "<think>hidden</think>Visible answer" })).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import { normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import type { ReplyToMode } from "../../config/types.js";
|
||||
import { normalizeTargetForProvider } from "../../infra/outbound/target-normalization.js";
|
||||
import { normalizeOptionalAccountId } from "../../routing/account-id.js";
|
||||
import { stripReasoningTagsFromText } from "../../shared/text/reasoning-tags.js";
|
||||
import { parseTelegramTarget } from "../../telegram/targets.js";
|
||||
import type { OriginatingChannelType } from "../templating.js";
|
||||
import type { ReplyPayload } from "../types.js";
|
||||
@@ -71,7 +72,18 @@ export function isRenderablePayload(payload: ReplyPayload): boolean {
|
||||
}
|
||||
|
||||
export function shouldSuppressReasoningPayload(payload: ReplyPayload): boolean {
|
||||
return payload.isReasoning === true;
|
||||
if (payload.isReasoning === true) {
|
||||
return true;
|
||||
}
|
||||
const text = payload.text;
|
||||
if (typeof text !== "string") {
|
||||
return false;
|
||||
}
|
||||
if (text.trimStart().toLowerCase().startsWith("reasoning:")) {
|
||||
return true;
|
||||
}
|
||||
const stripped = stripReasoningTagsFromText(text, { mode: "strict", trim: "both" });
|
||||
return !stripped && stripped !== text;
|
||||
}
|
||||
|
||||
export function applyReplyThreading(params: {
|
||||
|
||||
Reference in New Issue
Block a user