Skip to content

Commit 076da56

Browse files
Alix-007Peter Steinberger
andauthored
fix(imessage): recognize MiniMax mm: reasoning tags in reflection guard (completes #93767) (#93820)
* fix(imessage): detect MiniMax mm: namespaced reasoning tags in reflection guard The iMessage reflection guard's THINKING_TAG_RE only matched bare `<think>/<thought>` tags, so MiniMax's `<mm:think>` namespaced reasoning tags (and Anthropic's `antml:` prefix) were not recognized as reflected assistant content. When such reasoning leaked back inbound, the guard treated it as a normal user message instead of dropping it, allowing recursive echo amplification. Accept the known reasoning-tag namespace prefixes `(?:antml:|mm:)?` on the think/thought alternatives, mirroring the shared reasoning-tag contract in src/shared/text/reasoning-tags.ts (PR #93767). This is the remaining channel-monitor complement of #93767 for the iMessage path; the optional prefix is a pure recognition enhancement with no change to the bare-tag, code-region exemption, or other reflection patterns. Verified by driving the real detectReflectedContent export: <mm:think>secret</mm:think>visible -> isReflection=true (was false) <think>...</think> -> isReflection=true <think>secret</think> -> isReflection=true (no regression) "thinking about minimax algorithms" -> isReflection=false (no false-positive) `<mm:think>x</mm:think>` in code -> isReflection=false (code exemption kept) * chore: retrigger CI for real behavior proof check * refactor(imessage): tighten reflection guard coverage --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent 5a89484 commit 076da56

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

extensions/imessage/src/monitor/reflection-guard.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ describe("detectReflectedContent", () => {
3737
expect(result.matchedLabels).toContain("thinking-tag");
3838
});
3939

40+
it.each([
41+
{ provider: "Anthropic", tag: "antml:think" },
42+
{ provider: "MiniMax", tag: "mm:think" },
43+
])("detects $provider namespaced reasoning tags", ({ tag }) => {
44+
const result = detectReflectedContent(`<${tag}>secret</${tag}>visible`);
45+
expect(result.isReflection).toBe(true);
46+
expect(result.matchedLabels).toContain("thinking-tag");
47+
});
48+
4049
it("detects <relevant_memories> tags", () => {
4150
const result = detectReflectedContent("<relevant_memories>data</relevant_memories>");
4251
expect(result.isReflection).toBe(true);

extensions/imessage/src/monitor/reflection-guard.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { findCodeRegions, isInsideCode } from "openclaw/plugin-sdk/text-chunking
44
const INTERNAL_SEPARATOR_RE = /(?:#\+){2,}#?/;
55
const ASSISTANT_ROLE_MARKER_RE = /\bassistant\s+to\s*=\s*\w+/i;
66
// Require closing `>` to avoid false-positives on phrases like "<thought experiment>".
7-
const THINKING_TAG_RE = /<\s*\/?\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/i;
7+
// Keep known provider namespaces aligned with the public reasoning-tag contract
8+
// so reflected hidden reasoning cannot re-enter the agent loop.
9+
const THINKING_TAG_RE =
10+
/<\s*\/?\s*(?:(?:antml:|mm:)?(?:think(?:ing)?|thought)|antthinking)\b[^<>]*>/i;
811
const RELEVANT_MEMORIES_TAG_RE = /<\s*\/?\s*relevant[-_]memories\b[^<>]*>/i;
912
// Require closing `>` to avoid false-positives on phrases like "<final answer>".
1013
const FINAL_TAG_RE = /<\s*\/?\s*final\b[^<>]*>/i;

0 commit comments

Comments
 (0)