Skip to content

fix(auto-reply): support custom silent tokens with digits and punctuation in prefix matcher#100007

Closed
Simon-XYDT wants to merge 2 commits into
openclaw:mainfrom
Simon-XYDT:fix/silent-prefix-digits-99982
Closed

fix(auto-reply): support custom silent tokens with digits and punctuation in prefix matcher#100007
Simon-XYDT wants to merge 2 commits into
openclaw:mainfrom
Simon-XYDT:fix/silent-prefix-digits-99982

Conversation

@Simon-XYDT

@Simon-XYDT Simon-XYDT commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #99982

What Problem This Solves

isSilentReplyPrefixText never matches custom silent tokens containing digits or punctuation (e.g., NO_REPLY2, HELP-QUIET). The character guard /[^A-Z_]/.test(normalized) rejects any input containing non-letter chars, causing streamed prefix detection to fail for custom tokens with digits/hyphens.

Why This Change Was Made

The guard checked the input fragment instead of the token. Custom tokens with non-letter chars cannot be mistaken for natural language, so their prefixes are safe once the prefix includes a non-letter char from the token.

User Impact

Before: custom silent tokens like "NO_REPLY2" never match in the streaming prefix matcher.

After: prefix fragments containing a non-letter character from the token (e.g., "NO_" for "NO_REPLY2", "HELP-" for "HELP-QUIET") are correctly recognized. Pure-letter prefixes like "HE" for "HELP-QUIET" are still rejected.

Real behavior proof

  • Behavior addressed: streaming prefix matching for custom silent tokens with digits/punctuation
  • Real environment tested: Linux, Node 22, branch fix/silent-prefix-digits-99982
  • Commands run after this patch:
pnpm test src/auto-reply/tokens.test.ts
  • Evidence after fix:

Console output from self-contained Node script simulating character-by-character streaming:

--- Digit suffix token: "NO_REPLY2" ---
 Step | Prefix         | Matches?
------+----------------+---------
 wait  | "N"             | no - waiting for more chars
 wait  | "NO"            | no - waiting for more chars
 MATCH | "NO_"           | yes - streaming detected
 MATCH | "NO_R"          | yes - streaming detected
 MATCH | "NO_RE"         | yes - streaming detected
 MATCH | "NO_REP"        | yes - streaming detected
 MATCH | "NO_REPL"       | yes - streaming detected
 MATCH | "NO_REPLY"      | yes - streaming detected
 MATCH | "NO_REPLY2"     | yes - streaming detected

--- Hyphen token: "HELP-QUIET" ---
 Step | Prefix         | Matches?
------+----------------+---------
 wait  | "H"             | no - waiting for more chars
 wait  | "HE"            | no - waiting for more chars
 wait  | "HEL"           | no - waiting for more chars
 wait  | "HELP"          | no - waiting for more chars
 MATCH | "HELP-"         | yes - streaming detected
 MATCH | "HELP-Q"        | yes - streaming detected
 MATCH | "HELP-QU"       | yes - streaming detected
 MATCH | "HELP-QUI"      | yes - streaming detected
 MATCH | "HELP-QUIE"     | yes - streaming detected
 MATCH | "HELP-QUIET"    | yes - streaming detected

--- Digit-only token: "SILENT42" ---
 Step | Prefix         | Matches?
------+----------------+---------
 wait  | "S"             | no - waiting for more chars
 wait  | "SI"            | no - waiting for more chars
 wait  | "SIL"           | no - waiting for more chars
 wait  | "SILE"          | no - waiting for more chars
 wait  | "SILEN"         | no - waiting for more chars
 wait  | "SILENT"        | no - waiting for more chars
 MATCH | "SILENT4"       | yes - streaming detected
 MATCH | "SILENT42"      | yes - streaming detected

Natural language guard:
  isSilentReplyPrefixText("HE", "HELP-QUIET")    => false (reject natural lang)
  isSilentReplyPrefixText("HEL", "HELP-QUIET")   => false
  isSilentReplyPrefixText("HELP", "HELP-QUIET")  => false

Standard NO_REPLY still works:
  isSilentReplyPrefixText("NO", "NO_REPLY")      => true
  isSilentReplyPrefixText("NO_REPLY", "NO_REPLY")=> true

Unit tests:

Test Files  1 passed (1)
     Tests  43 passed (43)
  • Observed result after fix:
    1. NO_REPLY2: MATCH at "NO_" (underscore triggers)
    2. HELP-QUIET: MATCH at "HELP-" (hyphen triggers); pure-letter "HE","HEL","HELP" correctly rejected
    3. SILENT42: MATCH at "SILENT4" (digit triggers); pure-letter "SILENT" correctly rejected
    4. Standard NO_REPLY preserved
  • What was not tested: Live Telegram channel E2E

Evidence

  • Implementation: src/auto-reply/tokens.ts
  • Tests: src/auto-reply/tokens.test.ts (43 pass)
  • Real behavior proof: live Node runtime output above with character-by-character streaming simulation for 3 custom token patterns + natural lang guard + standard token
  • git diff --numstat: 2 files changed, 44 insertions(+), 1 deletion(-)

AI Assistance

This commit was co-authored with AI. The AI implemented the fix, tests, and PR description under human supervision.

…tion in prefix matcher [AI]

Remove the hard-coded /[^A-Z_]/ character guard from isSilentReplyPrefixText
that prevented streamed fragments of custom silent tokens containing digits or
punctuation (e.g. "NOREPLY2", "NO-ANSWER") from matching their token prefix.

Instead of a static character whitelist, use the configured token's own
alphabet: tokens with non-letter characters (digits, hyphens) allow partial
prefix matching since their fragments won't collide with natural-language
words. Tokens with only A-Z_ letters keep the existing underscore guard.

Fixes openclaw#99982

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clawsweeper

clawsweeper Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 12:07 AM ET / 04:07 UTC.

Summary
The PR updates isSilentReplyPrefixText and its tests so custom silent tokens with digits or punctuation can match streamed prefixes once the prefix reaches a distinguishing non-letter character or the full token.

PR surface: Source +5, Tests +26. Total +31 across 2 files.

Reproducibility: yes. source-level: current main rejects matching custom-token prefixes containing digits or hyphens at the hard-coded character guard before token comparison. I did not run tests because this review was required to keep the checkout read-only.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #99982
Summary: This PR is the candidate fix for the linked open issue describing the same custom silent-token digit and punctuation prefix guard bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] This helper directly controls whether streamed text is delivered or suppressed, so maintainers should explicitly accept the bounded message-delivery risk of widening custom-token prefix suppression beyond A-Z_ fragments.

Maintainer options:

  1. Land the helper fix after normal checks (recommended)
    Accept the bounded delivery risk because matching remains tied to configured token prefixes and the regression tests cover the new digit and punctuation cases.
  2. Ask for transport proof first
    If maintainers want channel-level confidence, request a configured-channel run showing a custom punctuated token being suppressed during streaming.

Next step before merge

  • No automated repair is needed; the remaining action is maintainer review and acceptance of the bounded message-delivery behavior change before landing.

Security
Cleared: The diff only changes an auto-reply token helper and tests; it does not touch dependencies, workflows, package metadata, secrets, or code-execution surfaces.

Review details

Best possible solution:

Land the narrow shared-helper fix with regression tests after maintainer review and required checks; avoid channel-specific workarounds or a new config surface.

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

Yes, source-level: current main rejects matching custom-token prefixes containing digits or hyphens at the hard-coded character guard before token comparison. I did not run tests because this review was required to keep the checkout read-only.

Is this the best way to solve the issue?

Yes. The PR fixes the shared prefix helper used by streaming and typing paths, preserves the natural-language guard, and avoids a channel-specific workaround or new configuration knob.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 02af382a06b3.

Label changes

Label justifications:

  • P2: This is a bounded auto-reply suppression bug affecting deployments that use custom silent tokens with digits or punctuation.
  • merge-risk: 🚨 message-delivery: The diff changes the shared predicate that decides whether streamed text is suppressed instead of delivered to a channel.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix live Node output simulating streamed prefixes for custom digit and punctuation tokens, plus focused test output for the changed helper.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live Node output simulating streamed prefixes for custom digit and punctuation tokens, plus focused test output for the changed helper.
Evidence reviewed

PR surface:

Source +5, Tests +26. Total +31 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 6 +5
Tests 1 26 0 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 37 6 +31

What I checked:

  • Root review policy read: The full 285-line root AGENTS.md was read; its review-beyond-diff and message-delivery merge-risk guidance applies to this shared auto-reply helper. (AGENTS.md:11, 02af382a06b3)
  • Current-main bug source: Current main rejects any normalized prefix fragment containing characters outside A-Z_ before comparing it with the configured token, which explains why digit and hyphen custom-token prefixes fail. (src/auto-reply/tokens.ts:313, 02af382a06b3)
  • Streaming caller: Streaming directive parsing passes the configured silent token into isSilentReplyPrefixText, so the helper directly affects streamed delivery suppression. (src/auto-reply/reply/streaming-directives.ts:106, 02af382a06b3)
  • Typing sibling path: Typing startup uses the same prefix helper with the configured silent token, so a helper-level fix covers the adjacent typing suppression invariant too. (src/auto-reply/reply/typing.ts:231, 02af382a06b3)
  • PR diff shape: The PR removes the hard-coded input-fragment character rejection, keeps token-prefix and underscore behavior, adds full-token matching, and allows non-letter custom-token prefixes only after the prefix contains a non-letter token character. (src/auto-reply/tokens.ts, 5f9ccbe1a804)
  • Focused regression coverage: The PR adds focused tests for digit tokens, hyphen tokens, non-matching custom prefixes, and pure-letter prefix rejection for a punctuated token. (src/auto-reply/tokens.test.ts:281, 5f9ccbe1a804)

Likely related people:

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.
Review history (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-04T17:04:21.907Z sha 5f9ccbe :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T17:32:42.756Z sha 5f9ccbe :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T17:39:11.598Z sha 5f9ccbe :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T23:56:24.299Z sha 5f9ccbe :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T00:02:52.412Z sha 5f9ccbe :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T00:37:16.505Z sha 5f9ccbe :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T00:50:29.067Z sha 5f9ccbe :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T04:01:20.690Z sha 5f9ccbe :: needs maintainer review before merge. :: none

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 4, 2026
…suppression

For custom tokens with non-letter characters (e.g., HELP-QUIET), require the
streamed prefix to include at least one of those non-letter characters before
marking it as silent. Pure-letter prefixes like "HE" for "HELP-QUIET" can no
longer suppress natural language text that happens to share the prefix.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Simon-XYDT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 4, 2026
@Simon-XYDT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 4, 2026
@Simon-XYDT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Jul 4, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared July 4, 2026 23:59 Inactive
@Simon-XYDT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 5, 2026
@Simon-XYDT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 5, 2026
@steipete steipete self-assigned this Jul 5, 2026
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for the contribution. This fix landed with contributor co-authorship preserved in #100258 (deac98eb7204fdb51589c5e369b95be128215e77).

I consolidated the source fixes into a maintainer takeover because the contributor branches were based on rewritten pre-main history; updating them directly would have pulled unrelated changes into the review surface. Closing this PR as superseded by the landed batch.

@steipete steipete closed this Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected behavior: isSilentReplyPrefixText never matches custom silent tokens containing digits/punctuation

2 participants