mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 16:14:58 +00:00
fix: tighten isSilentReplyText to match whole-text only
The suffix regex matched NO_REPLY at the end of any response, suppressing substantive replies when models (e.g. Gemini 3 Pro) appended NO_REPLY to real content. Replace prefix+suffix regexes with a single whole-string match. Only responses that are entirely the silent token (with optional whitespace) are now suppressed. Add unit tests for the fix. Fixes #19537
This commit is contained in:
@@ -11,12 +11,10 @@ export function isSilentReplyText(
|
||||
return false;
|
||||
}
|
||||
const escaped = escapeRegExp(token);
|
||||
const prefix = new RegExp(`^\\s*${escaped}(?=$|\\W)`);
|
||||
if (prefix.test(text)) {
|
||||
return true;
|
||||
}
|
||||
const suffix = new RegExp(`\\b${escaped}\\b\\W*$`);
|
||||
return suffix.test(text);
|
||||
// Only match when the entire response (trimmed) is the silent token,
|
||||
// optionally surrounded by whitespace/punctuation. This prevents
|
||||
// substantive replies ending with NO_REPLY from being suppressed (#19537).
|
||||
return new RegExp(`^\\s*${escaped}\\s*$`).test(text);
|
||||
}
|
||||
|
||||
export function isSilentReplyPrefixText(
|
||||
|
||||
Reference in New Issue
Block a user