Skip to content

fix(cron): suppress trailing NO_REPLY in announce delivery path [AI-assisted] - #65004

Merged
jalehman merged 2 commits into
openclaw:mainfrom
neo1027144-creator:fix/cron-announce-no-reply-mixed-text
Apr 15, 2026
Merged

jalehman merged 2 commits into
openclaw:mainfrom
neo1027144-creator:fix/cron-announce-no-reply-mixed-text

Conversation

@neo1027144-creator

Copy link
Copy Markdown
Contributor

Problem

Cron announce delivery sends the full agent response to the target channel when it contains NO_REPLY mixed with other text. The NO_REPLY suppression only works when it is the entire response.

Agents in cron/isolated sessions often emit analysis or summary text before appending NO_REPLY:

All 3 items already processed.

NO_REPLY

The delivery path in delivery-dispatch.ts uses isSilentReplyText() which requires an exact match (^\sNO_REPLY\s$), so this mixed text passes through and leaks to the user.

Root Cause

stripSilentToken() from okens.ts already handles trailing NO_REPLY removal, but was not called in the cron announce delivery path (delivery-dispatch.ts).

Fix

Use stripSilentToken() to detect trailing NO_REPLY tokens in both delivery code paths:

  1. deliverViaDirect (structured/direct path) — filter payloads by comparing text before and after stripping; suppress when different
  2. ** inalizeTextDelivery** (text-only path) — same comparison on synthesizedText

When the stripped result differs from the original, the payload carried a trailing NO_REPLY and delivery is suppressed via the existing inishSilentReplyDelivery() path.

Testing

Added 2 regression tests to delivery-dispatch.double-announce.test.ts:

  • Trailing NO_REPLY after summary in direct delivery → suppressed ✅
  • Trailing NO_REPLY after summary in text delivery → suppressed ✅

All 36 existing tests continue to pass (no regressions).

Fixes #64976

@neo1027144-creator neo1027144-creator changed the title fix(cron): suppress trailing NO_REPLY in announce delivery path fix(cron): suppress trailing NO_REPLY in announce delivery path [AI-assisted] Apr 11, 2026
@greptile-apps

greptile-apps Bot commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where cron agents that append NO_REPLY after summary text (e.g. `"All 3 items already processed.

NO_REPLY") would have their response leaked to the target channel because isSilentReplyText()only suppresses exact-match tokens. The fix appliesstripSilentToken() in both the structured (deliverViaDirect) and text (finalizeTextDelivery`) delivery paths, suppressing any payload where stripping the trailing token changes the content. Two targeted regression tests are added covering both code paths.

Confidence Score: 5/5

Safe to merge — the fix is correct, minimal, and targeted to the reported leak path.

Both delivery code paths now correctly suppress trailing NO_REPLY tokens, and two regression tests confirm the fix. The only finding is a P2 style note about a redundant guard that has no impact on correctness.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/cron/isolated-agent/delivery-dispatch.ts
Line: 437-444

Comment:
**Redundant `isSilentReplyText` guard in filter**

The `isSilentReplyText` check on line 439 is not needed — the `stripSilentToken` comparison immediately below already handles the exact-match case. For `"NO_REPLY"`, `stripSilentToken` yields `""`, so `"" !== "NO_REPLY".trim()` evaluates to `false` and the payload is filtered out just the same. The early return saves one regex call but adds a branch that duplicates intent already expressed by the comparison.

```suggestion
      const payloadsForDelivery = rawPayloads.filter((p) => {
        const text = p.text ?? "";
        const stripped = stripSilentToken(text, SILENT_REPLY_TOKEN);
        return stripped === text.trim();
      });
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(cron): suppress trailing NO_REPLY in..." | Re-trigger Greptile

Comment on lines +437 to +444
const payloadsForDelivery = rawPayloads.filter((p) => {
const text = p.text ?? "";
if (isSilentReplyText(text, SILENT_REPLY_TOKEN)) {
return false;
}
const stripped = stripSilentToken(text, SILENT_REPLY_TOKEN);
return stripped === text.trim();
});

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.

P2 Redundant isSilentReplyText guard in filter

The isSilentReplyText check on line 439 is not needed — the stripSilentToken comparison immediately below already handles the exact-match case. For "NO_REPLY", stripSilentToken yields "", so "" !== "NO_REPLY".trim() evaluates to false and the payload is filtered out just the same. The early return saves one regex call but adds a branch that duplicates intent already expressed by the comparison.

Suggested change
const payloadsForDelivery = rawPayloads.filter((p) => {
const text = p.text ?? "";
if (isSilentReplyText(text, SILENT_REPLY_TOKEN)) {
return false;
}
const stripped = stripSilentToken(text, SILENT_REPLY_TOKEN);
return stripped === text.trim();
});
const payloadsForDelivery = rawPayloads.filter((p) => {
const text = p.text ?? "";
const stripped = stripSilentToken(text, SILENT_REPLY_TOKEN);
return stripped === text.trim();
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cron/isolated-agent/delivery-dispatch.ts
Line: 437-444

Comment:
**Redundant `isSilentReplyText` guard in filter**

The `isSilentReplyText` check on line 439 is not needed — the `stripSilentToken` comparison immediately below already handles the exact-match case. For `"NO_REPLY"`, `stripSilentToken` yields `""`, so `"" !== "NO_REPLY".trim()` evaluates to `false` and the payload is filtered out just the same. The early return saves one regex call but adds a branch that duplicates intent already expressed by the comparison.

```suggestion
      const payloadsForDelivery = rawPayloads.filter((p) => {
        const text = p.text ?? "";
        const stripped = stripSilentToken(text, SILENT_REPLY_TOKEN);
        return stripped === text.trim();
      });
```

How can I resolve this? If you propose a fix, please make it concise.

@neo1027144-creator
neo1027144-creator force-pushed the fix/cron-announce-no-reply-mixed-text branch from 6298132 to 16a9441 Compare April 11, 2026 20:44

@neo1027144-creator neo1027144-creator left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re: redundant isSilentReplyText guard — good catch, I initially removed it but discovered that stripSilentToken uses getSilentTrailingRegex which is case-sensitive (no i flag), while isSilentReplyText uses getSilentExactRegex which has the i flag. Without the guard, mixed-case variants like No_Reply slip through. Kept isSilentReplyText as the case-insensitive exact-match layer and added a comment explaining the distinction.

@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: 16a944132a

ℹ️ 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 on lines +442 to +443
const stripped = stripSilentToken(text, SILENT_REPLY_TOKEN);
return stripped === text.trim();

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.

P2 Badge Make trailing NO_REPLY suppression case-insensitive

The new trailing-token guard relies on stripSilentToken, which currently matches NO_REPLY case-sensitively, so mixed-case variants like "All done\n\nNo_Reply" are still delivered in this direct-delivery branch (and the matching text-delivery branch later in the file). That leaves a real leak path for the same sentinel behavior this change is trying to block, especially since exact-token suppression is already case-insensitive.

Useful? React with 👍 / 👎.

@neo1027144-creator
neo1027144-creator force-pushed the fix/cron-announce-no-reply-mixed-text branch from 16a9441 to 7090734 Compare April 11, 2026 20:51

@neo1027144-creator neo1027144-creator left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed: trailing NO_REPLY suppression is now case-insensitive — text is uppercased before calling stripSilentToken since SILENT_REPLY_TOKEN is already uppercase. Added a test for mixed-case trailing No_Reply after summary text (37/37 passing).

@jalehman jalehman self-assigned this Apr 15, 2026
neo1027144-creator and others added 2 commits April 15, 2026 09:25
The cron announce delivery path only checked isSilentReplyText() which
requires the entire payload to be exactly NO_REPLY. When the agent
prepends summary text before the token (e.g. 'All 3 items processed.
\n\nNO_REPLY'), the exact match fails and the full response leaks to the
target channel.

Use stripSilentToken() to detect a trailing NO_REPLY token in both
deliverViaDirect (structured/direct path) and finalizeTextDelivery
(text-only path). When the stripped result differs from the original,
the payload carried a trailing NO_REPLY and delivery is suppressed.

The existing isSilentReplyText() guard is kept for case-insensitive
exact matches (e.g. 'No_Reply') since stripSilentToken uses a
case-sensitive regex.

Fixes openclaw#64976
@jalehman
jalehman force-pushed the fix/cron-announce-no-reply-mixed-text branch from 7090734 to b7f1996 Compare April 15, 2026 16:29
@jalehman
jalehman merged commit ee6b7da into openclaw:main Apr 15, 2026
40 of 41 checks passed
@jalehman

Copy link
Copy Markdown
Contributor

Merged via squash.

Thanks @neo1027144-creator!

xudaiyanzi pushed a commit to xudaiyanzi/openclaw that referenced this pull request Apr 17, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
kvnkho pushed a commit to kvnkho/openclaw that referenced this pull request Apr 17, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
Heetisk pushed a commit to Heetisk/openclaw that referenced this pull request Sep 28, 2026
…ssisted] (openclaw#65004)

Merged via squash.

Prepared head SHA: b7f1996
Co-authored-by: neo1027144-creator <[email protected]>
Co-authored-by: jalehman <[email protected]>
Reviewed-by: @jalehman
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.

[Bug]: (cron): announce delivery ignores NO_REPLY when agent prepends other text

2 participants