fix: silent token prefix detection leaks partial tokens to webchat#32112
Closed
x4v13r1120 wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix: silent token prefix detection leaks partial tokens to webchat#32112x4v13r1120 wants to merge 1 commit intoopenclaw:mainfrom
x4v13r1120 wants to merge 1 commit intoopenclaw:mainfrom
Conversation
isSilentReplyPrefixText required an underscore in the partial text, so streaming chunks like 'NO' (before '_REPLY' arrives) were not recognized as prefixes and leaked through to users as visible messages. Fix: remove the underscore requirement, add a minimum length of 2 to prevent single-character false positives, and require strict prefix matching (shorter than the full token). The uppercase-only check is applied to the original text (not after toUpperCase normalization) to prevent natural-language words like 'No' from matching. Fixes streaming NO_REPLY / HEARTBEAT_OK token leak on webchat.
Contributor
Greptile SummaryThis PR fixes a bug where partial streaming chunks of silent reply tokens (e.g., Key changes:
Confidence Score: 5/5
Last reviewed commit: 05d949f |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
During streaming, \isSilentReplyPrefixText\ is used to detect partial emission of silent tokens (\NO_REPLY, \HEARTBEAT_OK) before the full token is complete. However, the function required an underscore character to be present in the partial text:
\\ s
if (!normalized.includes('_')) return false;
\\
This means streaming chunks like \NO\ (emitted before _REPLY\ arrives) were not recognized as prefixes and leaked through to users as visible messages in webchat.
Root Cause
When a model streams \NO_REPLY, the text may arrive in chunks: \NO\ → _REPLY. The prefix detector should recognize \NO\ as a potential prefix of \NO_REPLY, but the underscore gate rejected it. Same issue affects \HEARTBEAT_OK\ — \HEART\ would also leak.
Fix
Tests
Updated \ okens.test.ts: