Repository navigation
Conversation
…line When the model outputs internal narration followed by NO_REPLY on a separate line, the preceding text is not user-facing content — it is reasoning/status that should be suppressed along with the token. Previously, stripSilentToken would remove the trailing NO_REPLY but deliver the preceding text to the user. This caused heartbeat narration, internal status summaries, and reasoning traces to leak as visible messages on Telegram and other channels. The fix introduces isSilentTokenOnOwnLine() which checks whether NO_REPLY appears on its own line (preceded by newline). When it does, the entire response is treated as silent. Inline occurrences like '😄 NO_REPLY' continue to strip only the token and deliver the emoji. Closes #42472 Refs #30916, #33544, #27959
Greptile SummaryThis PR fixes a message-leakage bug where internal model narration preceding Key changes:
Minor concern: Confidence Score: 4/5
Last reviewed commit: 1e3e88e |
| export function isSilentTokenOnOwnLine( | ||
| text: string, | ||
| token: string = SILENT_REPLY_TOKEN, | ||
| ): boolean { | ||
| if (!text) { | ||
| return false; | ||
| } | ||
| const escaped = escapeRegExp(token); | ||
| return new RegExp(`(\\n|^)\\s*${escaped}\\s*$`).test(text); | ||
| } |
There was a problem hiding this comment.
The regex pattern in isSilentTokenOnOwnLine is compiled fresh on every invocation, while the other regex-producing helpers in this file (getSilentExactRegex, getSilentTrailingRegex) cache their compiled patterns in a Map.
For consistency and to avoid unnecessary regex compilation in hot paths (like streaming message normalization), consider extracting a private getSilentOwnLineRegex(token) helper that follows the same memoization pattern as the sibling functions — check the map first, build and store on miss, then return the cached instance. This aligns the implementation with the established pattern in this file.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/tokens.ts
Line: 59-68
Comment:
The regex pattern in `isSilentTokenOnOwnLine` is compiled fresh on every invocation, while the other regex-producing helpers in this file (`getSilentExactRegex`, `getSilentTrailingRegex`) cache their compiled patterns in a `Map`.
For consistency and to avoid unnecessary regex compilation in hot paths (like streaming message normalization), consider extracting a private `getSilentOwnLineRegex(token)` helper that follows the same memoization pattern as the sibling functions — check the map first, build and store on miss, then return the cached instance. This aligns the implementation with the established pattern in this file.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: this conflicting normalizer-only branch is fully included in the same author's broader open follow-up, while the canonical issue remains open for the unresolved silent-token policy and delivery-proof decision. Canonical path: #42472 is still open and already tracks the same partial-leak problem with maintainer-review, product-decision, and linked-PR labels. So I’m closing this here and keeping the remaining discussion on #42472. Review detailsBest possible solution: Close this stale branch and keep review focused on the broader canonical follow-up and issue, where maintainers can choose one case-insensitive, all-path silent-token policy with real delivery proof. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main still strips trailing mixed Is this the best way to solve the issue? No. The branch is useful source work, but the maintainable solution is the broader current-main follow-up or replacement that applies one case-insensitive classifier across delivery/display paths with compatibility and real-behavior proof. Security review: Security review needs attention: Needs attention because the patch is security-relevant silent-reply leakage work, but the new own-line detector is case-sensitive while the existing silent-token contract accepts lowercase variants.
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 2c0c9c92f485. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
ClawSweeper applied the proposed close for this PR.
|
|
Reviving this PR with fresh production evidence (Sep 3–4, 2026). The bug this PR targets is still active in Reproduction (live)
Model output we observed (verbatim): Expected: nothing (the model intended silence). Actual: that literal text was delivered to the Feishu DM as a user-visible message ( Why the runtime didn't suppress itThe runtime correctly does not request delivery — Same shape as #42873#42873 documented: Field report: Same shape. Different narration language, same silent token on its own line. Closing the original hold reasonsThis PR was closed with
Behavior matrix (preserved from #42873)
Related (still open / closed-stale, same root cause)
Happy to test the patch once rebased onto |
Problem
When the model outputs internal narration/reasoning followed by
NO_REPLYon a separate line, the preceding text leaks to the user as a visible message.This is especially common with heartbeat tasks and weaker models that output internal status summaries before appending
NO_REPLY, but it also affects stronger models (Claude Opus 4.6) during heartbeat runs.The current
stripSilentTokenremoves the trailingNO_REPLYbut delivers the preceding text. This violates the model's intent — whenNO_REPLYappears on its own line, the preceding text is internal narration, not user-facing content.Fix
Introduces
isSilentTokenOnOwnLine()insrc/auto-reply/tokens.tswhich checks whetherNO_REPLYappears on its own line (preceded by\nor at the start of text). When it does, the entire response is treated as silent.Inline occurrences like
"😄 NO_REPLY"continue to usestripSilentTokenand deliver the non-token text, preserving the existing behavior from #30916.Decision matrix
"NO_REPLY"(exact)"😄 NO_REPLY"(inline)😄😄(unchanged)"text...\n\nNO_REPLY"(own line)text..."tasks:\n• ok\nNO_REPLY"(own line)tasks: • ok"NO_REPLY -- nope"(leading)Changes
src/auto-reply/tokens.ts: AddisSilentTokenOnOwnLine()src/auto-reply/reply/normalize-reply.ts: Use own-line check before falling back tostripSilentTokensrc/auto-reply/tokens.test.ts: Add tests forisSilentTokenOnOwnLinesrc/auto-reply/reply/reply-utils.test.ts: UpdatenormalizeReplyPayloadtests+99 / -15 lines, 4 files.
Closes #42472
Refs #30916, #33544, #27959, #30955