Repository navigation
Description
GitHub Issue Draft: Robust NO_REPLY Token Handling
Repo: openclaw/openclaw
Related: #28874 (NO_REPLY prefix leak), #39335 (webchat leak)
Title
feat(gateway): Strip NO_REPLY from both prefix AND suffix positions for robust suppression
Labels
enhancement, reliability
Body
Problem
Models frequently misuse the NO_REPLY token in two ways:
- Prefix position (covered by Gateway does not strip trailing text after NO_REPLY — causes phantom messages #28874):
NO_REPLY\n\nsome trailing text - Suffix position (new):
Task complete. NO_REPLY
The suffix case is arguably more common because models interpret "when you have nothing to say" as a completion signal rather than a silence signal. They output substantive content, then append NO_REPLY as if it were a sign-off.
Current Behavior
Gateway only suppresses messages where NO_REPLY is the exact entire content (after trimming). Any prefix or suffix text causes the full message to leak.
Proposed Fix
1. Gateway-level defense in depth:
function shouldSuppressMessage(text: string): { suppress: boolean; cleanedText?: string } {
const trimmed = text.trim();
// Exact match - full suppression
if (trimmed === 'NO_REPLY') {
return { suppress: true };
}
// Prefix position: "NO_REPLY\n..." or "NO_REPLY ..."
if (/^NO_REPLY[\s\n]/i.test(trimmed)) {
return { suppress: true }; // Discard entire message
}
// Suffix position: "...NO_REPLY" or "... NO_REPLY"
if (/[\s\n]NO_REPLY$/i.test(trimmed) || trimmed.endsWith('NO_REPLY')) {
const cleaned = trimmed.replace(/[\s\n]*NO_REPLY$/i, '').trim();
if (cleaned) {
return { suppress: false, cleanedText: cleaned }; // Strip suffix, deliver cleaned
}
return { suppress: true };
}
return { suppress: false };
}2. System prompt improvement:
Current:
When you have nothing to say, respond with ONLY: NO_REPLY
Proposed:
When your entire response should be suppressed (user sees nothing), respond with ONLY: NO_REPLY
NO_REPLY is NOT a completion marker. If you have content to share, just send the content without NO_REPLY.
Rationale
- Defense in depth: Even with perfect instructions, models will occasionally misuse tokens. The gateway should handle this gracefully.
- User experience: Leaked
NO_REPLYtokens confuse users and break trust. - Suffix stripping vs. suppression: For suffix position, stripping and delivering the cleaned content is better than full suppression — the model had something to say.
Test Cases
| Input | Expected Output |
|---|---|
NO_REPLY |
(suppressed) |
NO_REPLY\n\nHello |
(suppressed - malformed, discard) |
Task complete. NO_REPLY |
Task complete. |
Git is clean.\nNO_REPLY |
Git is clean. |
Regular message |
Regular message |
Environment
Observed across:
- Telegram, WhatsApp, Webchat channels
- Claude Opus, Claude Sonnet, GPT-5.3 Codex, Gemini models
- OpenClaw 2026.3.x
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
openclaw-barnacle commentedon Apr 25, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
clawsweeper commentedon Apr 26, 2026
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.
Close as duplicate: current main has partial NO_REPLY fixes, but the remaining mixed/partial suppression policy is already tracked by the broader open canonical issue.
Root-cause cluster
Relationship:
duplicateCanonical: #42472
Summary: This issue duplicates the broader open mixed/partial NO_REPLY suppression policy issue; current main has partial fixes but the remaining decision should stay centralized there.
Members:
canonical: Feature: post-process NO_REPLY to suppress partial leaks #42472 - Open issue already tracks post-processing NO_REPLY mixed-content suppression, has current ClawSweeper evidence, and carries the same product/security review labels.same_root_cause: Gateway does not strip trailing text after NO_REPLY — causes phantom messages #28874 - Closed report describes leading NO_REPLY with trailing text leaking through delivery, matching the prefix half of this issue.partial_overlap: [BUG] NO_REPLY fragment leaks to webchat UI #39335 - Closed webchat report covers partial NO_REPLY fragment leakage, which current gateway live-chat tests address separately.partial_overlap: fix(gateway): suppress NO_REPLY lead fragment in chat final message #39350 - Closed unmerged PR attempted a narrow webchat final-message fragment suppression for the related webchat leak.partial_overlap: fix(reply): suppress entire message when NO_REPLY appears on its own line #42873 - Closed unmerged PR proposed own-line suffix full suppression, overlapping but not safely canonical because it did not merge.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Canonical path: Close this issue as a duplicate and keep the broader NO_REPLY mixed-content policy discussion centralized in #42472.
So I’m closing this here and keeping the remaining discussion on #42472.
Review details
Best possible solution:
Close this issue as a duplicate and keep the broader NO_REPLY mixed-content policy discussion centralized in #42472.
Do we have a high-confidence way to reproduce the issue?
Yes, from source: current shared normalization still treats generic text followed by NO_REPLY as deliverable after stripping, while a separated leading token is not classified by the glued-leading helper.
Is this the best way to solve the issue?
No as a standalone issue: the remaining policy is already centralized in the broader canonical issue, and a fix should be reviewed there with the current partial fixes preserved.
Security review:
Security review needs attention: The underlying canonical issue remains security-relevant because mixed NO_REPLY handling can either leak internal text or suppress legitimate visible messages.
src/auto-reply/reply/normalize-reply.ts:70Current normalization can still deliver generic preamble text after stripping trailing NO_REPLY, but broad suppression would intentionally drop some replies that current tests preserve.
Confidence: 0.86
AGENTS.md: found and applied where relevant.
What I checked:
src/auto-reply/reply/normalize-reply.ts:70, 67c80e941ecf)src/auto-reply/reply/reply-utils.test.ts:195, 67c80e941ecf)src/cron/isolated-agent/delivery-dispatch.double-announce.test.ts:1815, 67c80e941ecf)src/auto-reply/tokens.ts:251, 153e3add6885)src/cron/isolated-agent/delivery-dispatch.ts:63, 16c608e3937e)Likely related people:
src/auto-reply/tokens.ts,src/auto-reply/reply/normalize-reply.ts,src/auto-reply/reply/reply-utils.test.ts)src/cron/isolated-agent/delivery-dispatch.ts,src/cron/isolated-agent/delivery-dispatch.double-announce.test.ts)src/auto-reply/tokens.ts,src/auto-reply/reply/normalize-reply.ts,src/auto-reply/reply/reply-utils.test.ts)src/auto-reply/tokens.ts,src/auto-reply/reply/reply-utils.test.ts,src/infra/outbound/payloads.test.ts)Codex review notes: model internal, reasoning high; reviewed against 67c80e941ecf.
smithstreeter commentedon Apr 27, 2026
Confirmed on 2026.4.x / Telegram / Claude Sonnet 4.6. Exact case: model replied NO_REPLY (exact, full message) to a simple 'Thanks' acknowledgment. The sentinel was delivered verbatim to the Telegram chat instead of being suppressed. Matches the exact-match trim path described here — the issue is the gateway suppression check isn't being applied before Telegram delivery.
tetesh commentedon May 13, 2026
Real-world impact of this remaining gap:
We run a cron job (every 5 minutes) that scans Alertmanager. The job invokes a deterministic Python runner and is supposed to return
NO_REPLYwhen there are no critical alerts. Despite explicit hard output contracts in the cron payload ("reply with EXACTLY: NO_REPLY, no other text"), the LLM appends explanatory text ~0.3-0.7% of the time — e.g."No new critical alerts found. Per contract: NO_REPLY."— and the full text reaches Telegram as-is because the cron announce delivery path only checksisSilentReplyText()(exact match/^\s*NO_REPLY\s*$/i).This means multiple cron jobs in our setup generate 1-2 unnecessary push notifications per day per job. For a monitoring context this is especially painful — the one thing you don't want is a channel that desensitizes people with noise. Multiply by N cron jobs and it becomes a real problem.
A
suppress-if-presentmode (or equivalent determinism) would completely eliminate this class of failures. The prompt-level contract will never be 100% reliable across all LLMs — this should be handled at the system level.Thanks for keeping this open, would love to see it move forward.
openclaw-barnacle commentedon Jun 8, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.