mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 03:42:43 +00:00
fix: prevent reasoning text leak through handleMessageEnd fallback
When enforceFinalTag is active (Google providers), stripBlockTags correctly returns empty for text without <final> tags. However, the handleMessageEnd fallback recovered raw text, bypassing this protection and leaking internal reasoning (e.g. "**Applying single-bot mention rule**NO_REPLY") to Discord. Guard the fallback with enforceFinalTag check: if the provider is supposed to use <final> tags and none were seen, the text is treated as leaked reasoning and suppressed. Also harden stripSilentToken regex to allow bold markdown (**) as separator before NO_REPLY, matching the pattern Gemini Flash Lite produces. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
15677133c1
commit
f534ea9906
@@ -288,7 +288,7 @@ export function handleMessageEnd(
|
||||
let mediaUrls = parsedText?.mediaUrls;
|
||||
let hasMedia = Boolean(mediaUrls && mediaUrls.length > 0);
|
||||
|
||||
if (!cleanedText && !hasMedia) {
|
||||
if (!cleanedText && !hasMedia && !ctx.params.enforceFinalTag) {
|
||||
const rawTrimmed = rawText.trim();
|
||||
const rawStrippedFinal = rawTrimmed.replace(/<\s*\/?\s*final\s*>/gi, "").trim();
|
||||
const rawCandidate = rawStrippedFinal || rawTrimmed;
|
||||
|
||||
Reference in New Issue
Block a user