mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 23:14:31 +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:
37
src/auto-reply/tokens.test.ts
Normal file
37
src/auto-reply/tokens.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { isSilentReplyText } from "./tokens.js";
|
||||
|
||||
describe("isSilentReplyText", () => {
|
||||
it("returns true for exact token", () => {
|
||||
expect(isSilentReplyText("NO_REPLY")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for token with surrounding whitespace", () => {
|
||||
expect(isSilentReplyText(" NO_REPLY ")).toBe(true);
|
||||
expect(isSilentReplyText("\nNO_REPLY\n")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for undefined/empty", () => {
|
||||
expect(isSilentReplyText(undefined)).toBe(false);
|
||||
expect(isSilentReplyText("")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for substantive text ending with token (#19537)", () => {
|
||||
const text = "Here is a helpful response.\n\nNO_REPLY";
|
||||
expect(isSilentReplyText(text)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for substantive text starting with token", () => {
|
||||
const text = "NO_REPLY but here is more content";
|
||||
expect(isSilentReplyText(text)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for token embedded in text", () => {
|
||||
expect(isSilentReplyText("Please NO_REPLY to this")).toBe(false);
|
||||
});
|
||||
|
||||
it("works with custom token", () => {
|
||||
expect(isSilentReplyText("HEARTBEAT_OK", "HEARTBEAT_OK")).toBe(true);
|
||||
expect(isSilentReplyText("Checked inbox. HEARTBEAT_OK", "HEARTBEAT_OK")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user