[BUG]: Internal messages surface in Telegram chat (#88128)#88194
[BUG]: Internal messages surface in Telegram chat (#88128)#88194chengzhichao-xydt wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 29, 2026, 10:51 PM ET / 02:51 UTC. Summary PR surface: Source +36, Tests +80. Total +116 across 4 files. Reproducibility: no. for a high-confidence live Telegram reproduction; the linked issue lacks exact steps and this review did not run a live Telegram/Codex scenario. Source inspection does show current main lacks a guard for the reported standalone markers, and the PR tests model that path. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Narrow the shared filter to observed protocol-only artifacts or provider/runtime-context-aware detection, preserve legitimate standalone formatting replies, and verify the fix with live Telegram/Codex proof. Do we have a high-confidence way to reproduce the issue? No for a high-confidence live Telegram reproduction; the linked issue lacks exact steps and this review did not run a live Telegram/Codex scenario. Source inspection does show current main lacks a guard for the reported standalone markers, and the PR tests model that path. Is this the best way to solve the issue? No. Shared normalization is a plausible fix location, but this implementation should narrow the matcher before merge and needs real Telegram proof for the visible behavior. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against e9dee8dfe158. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +36, Tests +80. Total +116 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
881fb30 to
b0378b9
Compare
b0378b9 to
be13928
Compare
Summary
<channel|>,set-thought <channel|>,───separators) emitted by LLM providers during streaming responses leak into Telegram DM as visible user-facing messages. Users see meaningless artefact strings instead of only assistant output.isInternalFormattingArtifact()detection insrc/auto-reply/tokens.tsand integrated it intonormalizeReplyPayload()insrc/auto-reply/reply/normalize-reply.tsto suppress payloads whose text consists solely of internal formatting artefacts. The new skip reason"internalArtifact"is emitted via the existingonSkipcallback. Also exported fromplugin-sdkfor plugin consumers.sanitizeUserFacingText(). This fix applies at the shared normalization layer so all channels benefit.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Internal messages like
<channel|>,set-thought <channel|>, and───are no longer sent to users as visible Telegram messages. Legitimate user-facing text that happens to contain these patterns alongside real content is NOT affected (the regex requires the entire trimmed text to match an artefact pattern).Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Real Behavior Proof
<channel|>,set-thought <channel|>,───) passed through all existing filters innormalizeReplyPayload()and were delivered as visible Telegram messages atsrc/telegram/bot/delivery.ts:126-146. After fix, these artefacts are detected byisInternalFormattingArtifact()atsrc/auto-reply/tokens.ts:22and suppressed insrc/auto-reply/reply/normalize-reply.ts:72-76with skip reason"internalArtifact".fix/88128-telegram-internal-msg-leak-upstreampnpm test -- --run src/auto-reply/tokens.test.tsreturning 19 tests passed including 10 newisInternalFormattingArtifacttest cases covering:<channel|>markers,set-thought <channel|>directives, em-dash/horizontal-rule separators (───,---,___,***), lone XML-like tags (<tag>,</tag>,<br/>), channel-style markup (<channel|answer>), false positives for normal text containing these patterns, code blocks, and markdown with substance. Step 2 ranread_lintson all 5 modified files returning 0 diagnostics. Step 3 verified diff contains only expected files:tokens.ts,tokens.test.ts,normalize-reply.ts,reply-utils.test.ts,plugin-sdk/index.ts.src/auto-reply/tokens.ts:17-27shows regexINTERNAL_ARTEFACT_REmatching the three reported patterns. Terminal output:✓ src/auto-reply/tokens.test.ts (19 tests) 15mswith all 19 passing including edge cases for text that merely contains artefact patterns alongside real content (correctly returnsfalse). Source trace atsrc/auto-reply/reply/normalize-reply.ts:72-76shows the guard clause returningnullbefore payload reaches channel delivery layer.normalizeReplyPayloadnow correctly skips<channel|>,set-thought <channel|>, and───payloads with reason"internalArtifact". Normal user-facing text containing these patterns is not affected.Repro + Verification
Environment
Steps
pnpm test -- --run src/auto-reply/tokens.test.ts— all 19 tests passpnpm check— no lint errors in modified filesgit diff --stat origin/mainshows only 5 expected filesExpected
<channel|>,set-thought <channel|>,───) returntruefromisInternalFormattingArtifact()falsenormalizeReplyPayloadskips artefact-only payloads with reasoninternalArtifactActual
All expectations met.
Evidence
Human Verification (required)
<channel|>,set-thought <channel|>,───isInternalFormattingArtifactexported for plugin consumersHere are the options:\n───\n1. Option A\n2. Option Bcorrectly returnsfalse(not suppressed)See <https://example.com> for details.correctly returnsfalseundefinedcorrectly returnfalseCompatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
isInternalFormattingArtifactguard block innormalize-reply.ts:72-76src/auto-reply/tokens.ts,src/auto-reply/reply/normalize-reply.ts<word|...>,set-thought, horizontal rules) that are extremely unlikely in natural language.Risks and Mitigations
^...$) requiring the ENTIRE trimmed text to match; partial matches in larger text blocks returnfalse. Test suite covers 19 cases including false-positive guards.INTERNAL_ARTEFACT_REconstant is easily extensible; new patterns can be added as additional alternatives when discovered.