#19576: fix: tighten isSilentReplyText to match whole-text only
size: XS
trusted-contributor
## Problem
`isSilentReplyText()` uses a suffix regex (`\bNO_REPLY\b\W*$`) that matches `NO_REPLY` at the **end** of any response text, even when preceded by substantive content. This causes legitimate replies to be silently suppressed and never delivered to the user.
Observed with Gemini 3 Pro which appends `NO_REPLY` to conversational replies, but any model could trigger this.
## Fix
Replace the prefix + suffix regex pair with a single whole-string match: `^\s*TOKEN\s*$`. Only responses that are **entirely** the silent token (with optional whitespace) are now treated as silent.
## Tests
Added `src/auto-reply/tokens.test.ts` with 7 test cases covering:
- Exact token match
- Whitespace variants
- Substantive text ending with token (the regression case)
- Substantive text starting with token
- Embedded token
- Custom token parameter
All tests pass: `npx vitest run src/auto-reply/tokens.test.ts`
Fixes #19537
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Replaces overly permissive prefix/suffix regex matching with strict whole-string matching for silent reply detection. The old implementation used `\bNO_REPLY\b\W*$` suffix pattern that matched `NO_REPLY` at the end of any text, causing legitimate replies ending with the token to be silently suppressed. The new `^\s*TOKEN\s*$` pattern only treats responses that are entirely the silent token (with optional whitespace) as silent, fixing the regression where models like Gemini 3 Pro append `NO_REPLY` to conversational responses.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no concerns
- The fix correctly addresses a critical bug where legitimate replies were being suppressed. The change is minimal, well-tested with 7 comprehensive test cases covering the regression and edge cases, and the logic change is straightforward and correct.
- No files require special attention
<sub>Last reviewed commit: a6e4442</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19916: fix: strict silent-reply detection to prevent false positives with ...
by hayoial · 2026-02-18
86.3%
#23761: fix: suppress partial NO_REPLY tokens at lifecycle boundary
by kami-saia · 2026-02-22
82.8%
#8504: fix: prevent false positives in isSilentReplyText for CJK content
by hanxiao · 2026-02-04
82.8%
#8493: fix(tui): filter NO_REPLY token from chat display
by gavinbmoore · 2026-02-04
79.8%
#19648: fix: suppress silent-reply partial tokens during streaming
by bradleypriest · 2026-02-18
79.1%
#17244: fix: strip TTS tags from agent replies before delivery (#14652)
by robbyczgw-cla · 2026-02-15
76.8%
#16361: Gateway: suppress NO_REPLY in webchat
by shadril238 · 2026-02-14
76.7%
#15118: Fix webchat ghost bubble when model replies with NO_REPLY
by jwchmodx · 2026-02-13
76.7%
#21462: fix(agents): hold back partial NO_REPLY token in pi-embedded streaming
by algal · 2026-02-20
76.1%
#21998: fix(models): prioritize exact model-id match over fuzzy scoring (#2...
by lailoo · 2026-02-20
75.7%