Skip to content

auto-reply: suppress reasoning-prefaced silent replies - #69472

Closed
pdd-cli wants to merge 1 commit into
openclaw:mainfrom
pdd-cli:fix/silent-reply-reasoning-preamble
Closed

pdd-cli wants to merge 1 commit into
openclaw:mainfrom
pdd-cli:fix/silent-reply-reasoning-preamble

Conversation

@pdd-cli

@pdd-cli pdd-cli commented Apr 20, 2026

Copy link
Copy Markdown

Summary

  • Suppress messages where the model's reply is a bare reasoning preamble (a word like think, thinking, thought, reasoning, or analysis on its own line) followed by the NO_REPLY sentinel, instead of delivering the chain-of-thought verbatim to users.
  • Collapse doubled trailing tokens such as NO_REPLY.NO_REPLY (observed with Gemini 3.x) inside the new check, while keeping the existing stripSilentToken contract unchanged.
  • Preserve the isSilentReplyText regex too permissive — suppresses substantive replies ending with NO_REPLY #19537 semantics: substantive replies that happen to end with NO_REPLY are still delivered.

Closes #69470.

Problem

When a reasoning-prone model emits its chain-of-thought as plain text content (not via structured thinking_* stream events or <thinking> XML tags) and concludes with the silent-reply sentinel, isSilentReplyPayloadText returns false and the whole message — reasoning plus NO_REPLY — is delivered to the messaging channel.

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."
...
Therefore, I should output NO_REPLY.NO_REPLY

The proper XML tag stripper in src/shared/text/reasoning-tags.ts cannot catch this form — there are no tags — and stripSilentToken intentionally leaves interject.NO_REPLY-style glued suffixes alone (per existing test at src/auto-reply/tokens.test.ts:64).

Fix

All changes localized to src/auto-reply/tokens.ts:

  1. New isReasoningPrefacedSilentReply(text, token) returns true when the message ends with the silent token and the preceding content is a bare reasoning preamble.
  2. Included in isSilentReplyPayloadText, so the single channel-agnostic gate at src/auto-reply/reply/reply-directives.ts:34 catches the leak for every channel.
  3. Private stripTrailingSilentTokensTolerant helper with its own regex (getSilentReasoningTrailingRegex) iterates to collapse doubled trailing tokens separated by punctuation. Kept out of the public stripSilentToken path so no other caller behavior shifts.

Test plan

🤖 Generated with Claude Code

When a model emits its chain-of-thought as plain text content (a bare
"think"/"thinking"/"thought"/"reasoning"/"analysis" heading followed by
prose) and concludes with the NO_REPLY sentinel, the channel-agnostic
silent-reply gate at src/auto-reply/reply/reply-directives.ts previously
treated the whole message as substantive and delivered it to users.

Add isReasoningPrefacedSilentReply, wire it into isSilentReplyPayloadText,
and include a dedicated tolerant trailing-strip helper so that doubled
token forms like "NO_REPLY.NO_REPLY" (observed with Gemini 3.x) collapse.
stripSilentToken keeps its existing conservative contract so no other
caller behavior shifts (preserves the "interject.NO_REPLY" no-op test).

Covered by new unit tests in src/auto-reply/tokens.test.ts.

Closes openclaw#69470

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b034b1662

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/auto-reply/tokens.ts
// src/shared/text/reasoning-tags.ts cannot catch this form because there are
// no tags to match.
const BARE_REASONING_PREAMBLE_RE =
/^\s*(?:think(?:ing)?|thought|reasoning|analysis)\s*:?\s*(?:\r?\n|$)/i;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Narrow preamble match before dropping NO_REPLY-suffixed messages

isReasoningPrefacedSilentReply now treats any payload whose post-token text merely starts with think|thinking|thought|reasoning|analysis as silent, so substantive replies like Analysis:\n<actual answer>\nNO_REPLY are discarded instead of being delivered with the trailing token stripped (the prior #19537 behavior). This creates a user-visible false positive whenever a model formats a normal response under an “Analysis” heading and accidentally appends NO_REPLY, causing complete message loss.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds isReasoningPrefacedSilentReply to suppress messages where a reasoning model leaks its chain-of-thought as plain text (headed by a bare preamble word like think/reasoning/analysis on its own line) and concludes with the NO_REPLY sentinel — including doubled forms like NO_REPLY.NO_REPLY. The fix is localized to src/auto-reply/tokens.ts and correctly wires into the existing isSilentReplyPayloadText gate without disturbing the stripSilentToken contract or the #19537 "substantive reply" semantics. Test coverage is thorough with 16 new cases.

Confidence Score: 5/5

Safe to merge — logic is sound, tests are comprehensive, and the change is correctly scoped to the silent-reply gate.

No P0 or P1 issues found. The regex design correctly restricts suppression to messages where the first line is a bare heading word (not inline prose), collapsing doubled tokens iteratively with a well-bounded loop. The only theoretical edge is very-short single-word strings like 'analysis.NO_REPLY' being suppressed without a newline, but that pattern cannot arise from any realistic model output and the trade-off is explicitly accepted in the PR design.

No files require special attention.

Reviews (1): Last reviewed commit: "auto-reply: suppress reasoning-prefaced ..." | Re-trigger Greptile

@pdd-cli

pdd-cli commented Apr 28, 2026

Copy link
Copy Markdown
Author

Superseded by #73153 — that PR includes this commit plus a follow-on fix in the embedded runner so the incomplete-turn / reasoning-only / empty-response retry paths recognize reasoning-prefaced silent replies as intentional silence (otherwise the runner re-prompts and surfaces a "couldn't generate a response" warning despite the auto-reply suppressor correctly stripping the leak from delivery). Reviewing #73153 instead is recommended; happy to close this one if maintainers prefer.

@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

This PR is superseded by open PR #73153 from the same author. Current main still lacks the requested reasoning-prefaced silent-reply handling, but #73153 carries the same auto-reply work plus the embedded-runner follow-on needed for the retry/warning path, so maintainer review should continue there.

Best possible solution:

Close this narrower PR as superseded and focus maintainer review on #73153, where the same auto-reply suppressor is paired with the embedded-runner retry/warning fix needed for the full user-visible behavior.

What I checked:

  • Author supersession comment: The author commented that auto-reply + runner: suppress reasoning-prefaced silent replies end-to-end #73153 supersedes this PR, includes the auto-reply suppressor, and adds the embedded-runner fix so reasoning-prefaced silent replies are treated as intentional silence instead of causing retries or a "couldn't generate a response" warning.
  • Canonical PR is open and broader: Live GitHub metadata shows auto-reply + runner: suppress reasoning-prefaced silent replies end-to-end #73153 is open, non-draft, authored by pdd-cli, and its body says it supersedes/combines this PR with a second embedded-runner commit for the end-to-end behavior. (8cc647de786d)
  • Canonical PR contains the same auto-reply patch plus runner follow-on: The auto-reply + runner: suppress reasoning-prefaced silent replies end-to-end #73153 commit list contains an auto-reply suppressor commit with the same behavior described here and a second commit, incomplete-turn: don't surface 'couldn't generate' for silent replies, and the file list adds runner code/tests beyond this PR's two auto-reply files. (8cc647de786d)
  • Current main lacks the auto-reply classifier: On current main, isSilentReplyPayloadText only delegates to exact silent-token detection and JSON envelope detection; there is no isReasoningPrefacedSilentReply path. (src/auto-reply/tokens.ts:74, a0a0ab4d9e2a)
  • Current main lacks the runner follow-on: On current main, resolveIncompleteTurnPayloadText still calls hasOnlySilentAssistantReply(params.attempt.assistantTexts), and isReasoningOnlyAssistantTurn / isEmptyResponseAssistantTurn do not first classify raw assistant content as a silent reply payload. (src/agents/pi-embedded-runner/run/incomplete-turn.ts:243, a0a0ab4d9e2a)
  • Security review pass: This PR changes only src/auto-reply/tokens.ts and src/auto-reply/tokens.test.ts; the superseding PR adds only runner TypeScript/tests. No workflow, dependency, lockfile, package script, release, artifact download, generated/vendor, permission, or secret-handling surface is introduced by this PR.

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 0835f9409aac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NO_REPLY silent reply suppression fails when model prefaces with reasoning or emits doubled token

1 participant