Skip to content

auto-reply + runner: suppress reasoning-prefaced silent replies end-to-end - #73153

Closed
pdd-cli wants to merge 2 commits into
openclaw:mainfrom
pdd-cli:fix/silent-reply-and-incomplete-turn
Closed

pdd-cli wants to merge 2 commits into
openclaw:mainfrom
pdd-cli:fix/silent-reply-and-incomplete-turn

Conversation

@pdd-cli

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

Copy link
Copy Markdown

Summary

Reasoning-prone models (notably Gemini 3.x) sometimes leak their chain-of-thought as plain text content that looks like think\n<analysis>\nNO_REPLY — a silent-reply sentinel preceded by a bare reasoning preamble. Two layers need to recognize this as intentional silence:

  1. The outbound silent-reply gate — so the chain-of-thought doesn't get delivered to the messaging channel.
  2. The runner's incomplete-turn classifier and retry resolvers — so the runner doesn't re-prompt the model on every spam decision and doesn't surface a "Agent couldn't generate a response" warning to users for an intentional silence.

This PR fixes both.

Supersedes / combines #69472. The first commit is the auto-reply suppressor from that PR; the second commit extends the same fix into the embedded runner so the incomplete-turn / reasoning-only / empty-response retry paths short-circuit the same way. Each commit is independently reviewable; the runner change depends on the auto-reply change to compile correctly (isReasoningPrefacedSilentReply is exported from auto-reply/tokens.ts).

Closes #69470, #69191 (silent-reply leak class).

Production evidence

pdd-public agent on Discord with Gemini 3.1 Pro produced this exact assistant text on every spam-in-#general decision:

think
Another advertisement. Ignore.NO_REPLY

Before this PR:

  • The auto-reply path delivered the literal text to the channel (chain-of-thought leak).
  • After we patched the auto-reply suppressor (commit 1 here / auto-reply: suppress reasoning-prefaced silent replies #69472), the chain-of-thought stopped being delivered, but the runner saw payloads=0 stopReason=stop and:
    • re-prompted the model via the empty-response and reasoning-only retry paths (extra LLM cost on every spam message), and
    • posted "⚠️ Agent couldn't generate a response. Please try again." to the channel.

Both symptoms are gone with this PR.

What's in each commit

Commit 1 — auto-reply: suppress reasoning-prefaced silent replies

src/auto-reply/tokens.ts and src/auto-reply/tokens.test.ts. Adds isReasoningPrefacedSilentReply and wires it into isSilentReplyPayloadText. Uses a tolerant trailing-strip helper that handles doubled tokens (NO_REPLY.NO_REPLY) and reasoning preambles (think/thinking/thought/reasoning/analysis) on their own line. Public stripSilentToken is unchanged so the existing interject.NO_REPLY no-op contract is preserved (the existing test at tokens.test.ts:64 continues to pass).

Commit 2 — incomplete-turn: don't surface 'couldn't generate' for silent replies

src/agents/pi-embedded-runner/run/incomplete-turn.ts and src/agents/pi-embedded-runner/run.incomplete-turn.test.ts. Three call-site changes so the silent-reply classification flows into every code path that examines the assistant turn:

  • hasOnlySilentAssistantReply now also reads lastAssistant.content text parts (assistantTexts can be empty when the streaming chunker filters drop the assistant text before the run wrapper records it).
  • isReasoningOnlyAssistantTurn returns false when the message text classifies as a silent reply payload — silent NO_REPLY is intentional silence, not unfinished reasoning.
  • isEmptyResponseAssistantTurn returns false for the same reason — gates the empty-response retry resolver against firing on intentional silence.

Regression test uses the exact production assistant payload from the Discord incident.

Test plan

  • pnpm test src/auto-reply/tokens.test.ts — passes (38 tests, includes new reasoning-preface and doubled-token cases).
  • pnpm test src/agents/pi-embedded-runner/run.incomplete-turn.test.ts — passes (84 tests, includes new regression for the runner false positive).
  • Deployed locally on the gateway that originally exhibited this; both symptoms gone after rebuild + restart.

Notes for review

  • The runner change is conservative — it only short-circuits when isSilentReplyPayloadText returns true. Without this PR's commit 1, the runner change is a no-op for the reasoning-prefaced case (and an exact-NO_REPLY already short-circuits via existing logic, so behavior on that path is unchanged).
  • Both commits keep the existing #19537 semantics: substantive replies that happen to end with NO_REPLY are still delivered.

🤖 Generated with Claude Code

Prompt Driven added 2 commits April 27, 2026 18:44
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
Follow-on to PR openclaw#69472 (auto-reply silent-reply suppressor for reasoning-
prefaced sentinels like "think\n...\nNO_REPLY"). The outbound suppressor
correctly stripped these from delivery, but the runner's incomplete-turn
classifier and three retry resolvers (planning-only / reasoning-only /
empty-response) saw payloadCount=0 + assistantTexts=[] and re-prompted
the model on every spam decision. Each retry burned LLM tokens and the
final classifier surfaced a "Agent couldn't generate a response" warning
to the channel even though the original silence was intentional.

Three minimal call-site changes in src/agents/pi-embedded-runner/run/
incomplete-turn.ts:
- hasOnlySilentAssistantReply now also reads lastAssistant.content text
  parts (assistantTexts can be empty when streaming/chunker filters drop
  the assistant text before the run wrapper records it).
- isReasoningOnlyAssistantTurn returns false when the message text is a
  silent reply payload — silent NO_REPLY is intentional silence, not an
  unfinished reasoning turn that should be retried.
- isEmptyResponseAssistantTurn returns false for the same reason — gates
  the empty-response retry resolver against firing on intentional silence.

Regression test in run.incomplete-turn.test.ts uses the exact Discord
session payload that triggered this on April 24 and 27.

Closes openclaw#69470 (follow-on)
@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds end-to-end suppression of reasoning-prefaced silent replies (e.g. think\nAnalysis.\nNO_REPLY) from Gemini chain-of-thought leakage, fixing both the outbound delivery gate in auto-reply/tokens.ts and three code paths in the embedded runner's incomplete-turn classifier that were triggering false-positive retries and the "couldn't generate a response" warning.

The logic is correct: BARE_REASONING_PREAMBLE_RE is anchored to the start of the stripped text, the tolerant trailing-strip loop is capped and handles doubled tokens cleanly, the #19537 no-op contract is preserved, and the runner changes conservatively gate behind isSilentReplyPayloadText. Test coverage is thorough, including the exact production payload from the Discord incident.

Confidence Score: 5/5

Safe to merge — no correctness issues found and both code paths are well-tested.

No P0 or P1 issues identified. Logic for regex construction, iterative token stripping, duplicate-source collection, and all three runner guard sites is correct. The #19537 substantive-reply contract is preserved. Test coverage includes the exact production incident payload, doubled-token forms, edge cases for each reasoning heading word, and integration tests for isSilentReplyPayloadText.

No files require special attention.

Reviews (1): Last reviewed commit: "incomplete-turn: don't surface 'couldn't..." | Re-trigger Greptile

@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed May 26, 2026, 12:58 AM ET / 04:58 UTC.

Summary
The PR adds reasoning-prefaced NO_REPLY detection to auto-reply token classification and wires that classifier into embedded-runner incomplete-turn retry and warning logic.

PR surface: Source +142, Tests +128. Total +270 across 4 files.

Reproducibility: yes. from source: current main's shared silent-reply payload gate does not classify think\n...\nNO_REPLY, and the current runner only checks assistantTexts before the incomplete-turn warning path. I did not run tests because this review was read-only.

Review metrics: 1 noteworthy metric.

  • Delivery decision paths: 2 changed. The PR changes both outbound silent-reply classification and embedded-runner retry/warning behavior, so channel delivery must be checked before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Add redacted after-fix real behavior proof showing the reasoning-prefaced silent reply is suppressed and no couldn't-generate warning is posted.
  • Import or otherwise type AssistantMessage correctly, then rebase the branch onto current main and resolve the dirty runner drift.

Proof guidance:
Needs real behavior proof before merge: The PR body includes production before-context and a local deployment claim, but no redacted after-fix terminal output, logs, screenshot, recording, copied live output, or linked artifact showing the real delivery path after the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A real channel transcript would materially prove the user-visible suppression and absence of the warning after the fix. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

visual task: verify a reasoning-prefaced NO_REPLY spam decision is not posted and no couldn't-generate warning appears.

Risk before merge

  • As submitted, the branch is dirty against current main, and the embedded-runner file has since changed around delivery evidence, clientToolCalls, and retry guards; the merge result needs a rebase before it is knowable.
  • The PR intentionally changes whether reasoning-prefaced NO_REPLY text is delivered, retried, or suppressed, so a classifier mistake can either leak reasoning to channels or drop a user-visible reply.
  • Contributor-supplied after-fix proof is still missing; the body has a local deployment claim but no redacted terminal output, logs, screenshot, recording, copied live output, or linked artifact showing the real path after the patch.

Maintainer options:

  1. Refresh the branch before review (recommended)
    Rebase onto current main and resolve the embedded-runner drift while preserving the existing delivery-evidence and retry guards.
  2. Require live delivery proof
    Ask for redacted after-fix output, logs, screenshot, recording, or linked artifact showing the affected channel no longer receives the reasoning text or warning.
  3. Replace with a narrow maintainer patch
    If the branch cannot be refreshed cleanly, maintainers can close it after a smaller replacement PR lands with the same classifier and runner coverage.

Next step before merge
Human PR handling is needed because contributor after-fix proof is missing, the branch is dirty against main, and the remaining blocker includes a compile fix plus rebase validation.

Security
Cleared: No new security or supply-chain concern was found; the diff is limited to TypeScript message classification and tests, with no dependency, workflow, secret, or code-download changes.

Review findings

  • [P2] Import the assistant message type — src/agents/pi-embedded-runner/run/incomplete-turn.ts:283
Review details

Best possible solution:

Refresh the branch on current main, fix the unresolved type, preserve the shared classifier plus runner regression coverage, and require redacted live proof that the reasoning-prefaced silent reply is neither delivered nor retried into a warning.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main's shared silent-reply payload gate does not classify think\n...\nNO_REPLY, and the current runner only checks assistantTexts before the incomplete-turn warning path. I did not run tests because this review was read-only.

Is this the best way to solve the issue?

No, not as submitted: the design direction is a narrow fit for the bug, but the branch needs the missing type import, a current-main rebase, and real after-fix proof before it is the best merge path.

Full review comments:

  • [P2] Import the assistant message type — src/agents/pi-embedded-runner/run/incomplete-turn.ts:283
    The new helper signatures reference AssistantMessage, but this file still only imports AgentMessage. TypeScript will fail on both new signatures until the correct assistant message type is imported or the signature uses the existing EmbeddedRunAttemptResult["lastAssistant"] type.
    Confidence: 0.93

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 23e9bc8c0b61.

Label changes

Label justifications:

  • P1: The reported behavior can leak model reasoning into messaging channels and then post a false couldn't-generate warning on an intentional silent reply.
  • merge-risk: 🚨 message-delivery: The diff changes core suppression and retry decisions that determine whether a channel receives text, silence, or an error warning.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body includes production before-context and a local deployment claim, but no redacted after-fix terminal output, logs, screenshot, recording, copied live output, or linked artifact showing the real delivery path after the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +142, Tests +128. Total +270 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 148 6 +142
Tests 2 128 0 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 276 6 +270

What I checked:

  • Repository policy read: Root AGENTS.md and the scoped src/agents embedded-runner guides were read; their review guidance affected the focus on whole delivery surfaces, runner behavior, and real behavior proof. (AGENTS.md:1, 23e9bc8c0b61)
  • Current main silent-reply classifier lacks the proposed reasoning-preface path: On current main, isSilentReplyPayloadText only accepts exact silent tokens or JSON action envelopes, so a think\n...\nNO_REPLY body is not recognized by this shared gate. (src/auto-reply/tokens.ts:74, 23e9bc8c0b61)
  • Current main runner only checks collected assistant text for silent replies: Current main calls hasOnlySilentAssistantReply(params.attempt.assistantTexts) before emitting the incomplete-turn warning; it does not inspect lastAssistant.content for a stripped raw silent reply. (src/agents/pi-embedded-runner/run/incomplete-turn.ts:267, 23e9bc8c0b61)
  • PR branch has a compile-blocking unresolved type: The PR head references AssistantMessage in new helper signatures at lines 283 and 308, but the file imports only AgentMessage; this needs an import or a local type from EmbeddedRunAttemptResult. (src/agents/pi-embedded-runner/run/incomplete-turn.ts:283, 8cc647de786d)
  • PR adds a focused runner regression test: The PR head adds a test for think\nAnother advertisement. Ignore.NO_REPLY with empty assistantTexts, matching the reported Discord/Gemini shape. (src/agents/pi-embedded-runner/run.incomplete-turn.test.ts:81, 8cc647de786d)
  • Related history for shared silent-reply gate: isSilentReplyPayloadText was added by commit 17479ce for JSON-wrapped NO_REPLY suppression, making it the natural shared classifier for this fix. (src/auto-reply/tokens.ts:74, 17479ceb439a)

Likely related people:

  • steipete: Current-main blame for the touched classifier and runner areas points to the latest main refresh, and recent history shows repeated NO_REPLY and embedded-runner maintenance in these files. (role: recent area contributor; confidence: medium; commits: d00d0a21c2dd, a374c3a5bfd5; files: src/auto-reply/tokens.ts, src/agents/pi-embedded-runner/run/incomplete-turn.ts)
  • Robin Waslander: Commit 17479ce added isSilentReplyPayloadText and applied it to channel delivery gates, which is the shared classifier this PR extends. (role: introduced shared silent-reply classifier; confidence: high; commits: 17479ceb439a; files: src/auto-reply/tokens.ts)
  • Josh Lehman: Commit 14779ea added the reasoning-only and empty-response retry paths in the embedded runner that this PR updates for intentional silent replies. (role: introduced adjacent runner retry behavior; confidence: high; commits: 14779eaeb0d9; files: src/agents/pi-embedded-runner/run/incomplete-turn.ts)
  • Ayaan Zaidi: Recent history includes NO_REPLY hardening work around cron announcement suppression, making this a useful adjacent routing candidate for message-suppression behavior. (role: adjacent NO_REPLY suppression contributor; confidence: medium; commits: 16c608e3937e; files: src/cron/isolated-agent/delivery-dispatch.ts, src/auto-reply/tokens.ts)
  • Frank Yang: Commit 153e3ad worked on leading silent-token suppression and streaming paths near the same shared auto-reply token boundary. (role: adjacent auto-reply hardening contributor; confidence: medium; commits: 153e3add6885; files: src/auto-reply/tokens.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 25, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 26, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 26, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

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

2 participants