Repository navigation
Description
Bug
When an agent is configured to reply with the NO_REPLY sentinel (for example during spam/ad handling in Discord), the agent's model can emit reasoning as plain text content instead of (or in addition to) structured thinking events. The resulting message is posted to the messaging channel verbatim.
Observed Discord output:
think
The user's message is from "Aftermath" in the #general channel.
The channel topic is: "Topics of general interest around PDD. No advertisement or soliciting."
Aftermath's message is a self-promotional advertisement offering assistance with automation projects, websites, mobile apps, and AI systems.
According to the summary of progress and key decisions:
"NO_REPLY to Spam/Ads: Although ads violate the channel rules, the bot lacks moderation capabilities and its primary directive is PDD support. Silence is the required action."
Therefore, I should output NO_REPLY.NO_REPLY
This should have been suppressed (the agent correctly decided not to reply), but the user sees the model's reasoning instead.
Root Cause
Three layered issues in src/auto-reply/tokens.ts:
-
isSilentReplyTextrequires the message to be exactlyNO_REPLY. Per isSilentReplyText regex too permissive — suppresses substantive replies ending with NO_REPLY #19537, anything else is considered substantive and passes through. When Gemini (or any reasoning model) emits reasoning as plain text content followed by the silent token, the content disqualifies the message from suppression. -
stripSilentTokendoes not collapse doubled tokens or tolerate punctuation. The regex(?:^|\s+|\*+)${token}\s*$matches only when the trailing token is preceded by whitespace, start-of-string, or asterisks. The observed output"...NO_REPLY.NO_REPLY"has a literal.between the two tokens, so neither token gets stripped and the tail is not recognized as silent. -
stripReasoningTagsFromText(insrc/shared/text/reasoning-tags.ts) only matches XML-style tags (<think>,<thinking>,<thought>,<antthinking>,<final>). It cannot catch Markdown-style reasoning preambles like a barethink\n...heading at the start of the message.
Why Now
The same silent-reply path has existed for a while. This became visible once the gateway stabilized around 2026-04-16 (google-vertex ADC auth, dist/plugin-sdk build, context-overflow thrash all resolved). Prior to that, the agent frequently failed before ever reaching the silent-reply check. Additionally, raising agents.defaults.contextTokens from 80000 to 500000 gave Gemini more headroom to emit verbose reasoning as content.
Proposed Fix
Narrow, channel-agnostic change in src/auto-reply/tokens.ts:
- Iterate
stripSilentTokenso repeatedNO_REPLYoccurrences with intervening punctuation collapse to empty. - Add
isReasoningPrefacedSilentReply(text, token)that returnstruewhen the message ends with the silent token and the preceding content is a bare reasoning preamble (a word likethink,thinking,thought,reasoning, oranalysison its own line). This preserves the isSilentReplyText regex too permissive — suppresses substantive replies ending with NO_REPLY #19537 semantics — substantive replies ending with NO_REPLY are still delivered — while suppressing reasoning-wrapped silent replies. - Include the new check in
isSilentReplyPayloadTextso the single gate atsrc/auto-reply/reply/reply-directives.ts:34catches it.
Scope
- No change to
stripReasoningTagsFromText(XML tag stripping stays as-is). - No channel-specific changes; the fix lives in the shared auto-reply layer so all channels benefit.
- Existing behavior (isSilentReplyText regex too permissive — suppresses substantive replies ending with NO_REPLY #19537: "do not suppress substantive replies that happen to end with NO_REPLY") is preserved.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
martingarramon commentedon Apr 26, 2026
Confirmed all three sub-claims on current
main(edb618c6c4).1.
isSilentReplyTextrequires exactly the token, modulo whitespace.src/auto-reply/tokens.ts:10-19builds the matcher as/^\s*${escaped}\s*$/i. The check is intentional per the comment at line 40 ("This prevents substantive replies ending with NO_REPLY from being suppressed (#19537)"). So any reasoning preamble + token combo bypasses suppression as designed — your example payload ends up returningfalsefromisSilentReplyText.2.
stripSilentTokenregex doesn't handle.NO_REPLYboundary.tokens.ts:21-30builds/(?:^|\s+|\*+)${escaped}\s*$/i. The trailing-token alternation accepts only start-of-string, whitespace, or asterisks before the token. Your"...output NO_REPLY.NO_REPLY"has a literal.between the doubled tokens — the trailing token's preceding char isY(from the firstNO_REPLY), which doesn't match either; even if you peeled the second one, the first token's preceding char is.. Neither token gets stripped.Worth noting the leading side has analogous coverage that the trailing side lacks:
stripLeadingSilentToken(tokens.ts:124) handles(?:\s*${escaped})+— one or more leading occurrences with whitespace. The trailing side has no equivalent iteration.3.
stripReasoningTagsFromTextis XML-only.src/shared/text/reasoning-tags.ts:5definesQUICK_TAG_RE = /<\s*\/?\s*(?:(?:antml:)?(?:think(?:ing)?|thought)|antthinking|final)\b/i;. The function early-returns at line 30-32 when this regex doesn't match, so any non-angle-bracketed reasoning preamble (Markdownthink\n..., bareThinking:headers) is passed through verbatim.On the proposed fix: the three-step plan (iterate
stripSilentTokento collapse repeated tokens with intervening punctuation, addisReasoningPrefacedSilentReply, wire it intoisSilentReplyPayloadText) lands cleanly in this layer without touchingstripReasoningTagsFromText. The single-gate threading viasrc/auto-reply/reply/reply-directives.ts:34keeps the change channel-agnostic.One subtle case worth covering in the iteration step: punctuation characters between repeated tokens vary by model (
.,:,,, sometimes\n). Anchoring on\s*[\.\,\:\;\!\?\n]*\s*between repeats — rather than just punctuation — keeps Gemini-styleNO_REPLY.NO_REPLYand Claude-styleNO_REPLY\nNO_REPLYboth covered, while still preserving the #19537 boundary (a substantive sentence ending with one bareNO_REPLYshould still pass through).Happy to take a swing at the PR if no one else is on it.
clawsweeper commentedon Apr 26, 2026
Closing this as duplicate or superseded after Codex automated review.
Issue #69470 should close as superseded by the directly linked open PR #69472, which is the active code/test vehicle for the same remaining bug. Current main does not yet implement the requested tolerant reasoning-prefaced NO_REPLY suppression, so this is not an implemented-on-main close.
Best possible solution:
Use PR #69472 as the canonical active tracker and review or land that shared
src/auto-reply/tokens.tsfix, preserving #19537 exact-token semantics while adding narrowly tested reasoning-prefaced/doubled-token suppression.What I checked:
isSilentReplyPayloadTextreturns onlyisSilentReplyText(text, token) || isSilentReplyEnvelopeText(text, token), andisSilentReplyTextintentionally matches only the exact silent token with surrounding whitespace to preserve isSilentReplyText regex too permissive — suppresses substantive replies ending with NO_REPLY #19537 behavior. (src/auto-reply/tokens.ts:32, 4a3030df9efa)interject.NO_REPLY, soNO_REPLY.NO_REPLYis not collapsed by the current public strip path. (src/auto-reply/tokens.ts:21, 4a3030df9efa)parseReplyDirectivescomputesisSilentthroughisSilentReplyPayloadText, so the proposed fix belongs in the shared auto-reply token layer rather than a Discord-only path. (src/auto-reply/reply/reply-directives.ts:33, 4a3030df9efa)stripReasoningTagsFromTextquick-checks only angle-bracket thinking/final tags and returns unchanged when no such tag exists, so a barethinkheading is outside that helper's current contract. (src/shared/text/reasoning-tags.ts:5, 4a3030df9efa)auto-reply: suppress reasoning-prefaced silent replies, cross-referenced from this issue, withCloses #69470, changes localized tosrc/auto-reply/tokens.tsandsrc/auto-reply/tokens.test.ts, and tests covering reasoning-prefaced messages, doubledNO_REPLY.NO_REPLY, and isSilentReplyText regex too permissive — suppresses substantive replies ending with NO_REPLY #19537 preservation. (6b034b1662ae)So I’m closing this here and keeping the remaining discussion on the canonical linked item.
Codex Review notes: model gpt-5.5, reasoning high; reviewed against 4a3030df9efa.