Repository navigation
fix(agents): stop messaging dedupe from dropping final replies that quote a short tool send - #118178
Conversation
…uote a short tool send The forward substring check in isMessagingToolDuplicateNormalized treated any reply containing a prior message-tool send as a duplicate, with no length floor. A short interim update sent via the message tool then suppressed the entire final reply that restated it, and the user never received the answer. The reverse direction already carried a 0.5 length ratio floor. Apply the same floor to the forward direction so a reply is only deduped when the prior send covers at least half of it.
|
Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 11:18 AM ET / 15:18 UTC. ClawSweeper reviewWhat this changesThe PR makes message-tool text deduplication require a prior send to cover at least half of a final reply before suppressing that reply. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: current main and the latest release still suppress a substantive final reply whenever it contains a prior short message-tool send. The PR repairs that shared decision point with no blocking finding. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw records text sent through the agent message tool, then passes final and streamed assistant text through shared deduplication before channel delivery. The decision determines whether users receive an already-sent reply or the remaining substantive response. flowchart LR
A[Channel message] --> B[Agent runtime]
B --> C[Message-tool send record]
B --> D[Final or streamed reply]
C --> E[Shared text deduplication]
D --> E
E --> F{Prior send covers reply?}
F -->|Yes| G[Suppress duplicate]
F -->|No| H[Deliver reply]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +11. Total +11 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Mantis proof suggestionOptional Telegram Desktop proof would add transport-level confirmation that the substantive final reply remains visible after an interim tool send. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one symmetric containment rule at the shared dedupe owner after current-merge validation, preserving suppression for close restatements while delivering substantive replies. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s forward containment branch suppresses any final reply that includes a prior send, and the PR provides before/after production payload-assembly output for the affected routed path. Is this the best way to solve the issue? Yes. Applying the threshold in the shared predicate is the narrowest maintainable repair because final, follow-up, and streaming consumers already route through it. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cb2965dddece. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
…cope * origin/main: (70 commits) fix(clickclack): preserve MIME extension for unnamed uploads (openclaw#119646) fix(memory): keep post-ready RPCs responsive (openclaw#119710) fix(browser): preserve locale, timezone, and device overrides (openclaw#119695) fix(agents): stop messaging dedupe from dropping final replies that quote a short tool send (openclaw#118178) test(agents): batch code mode budget proof (openclaw#119699) fix(memory): keep gateway RPCs responsive during startup (openclaw#119676) improve(ui): trail transient session status beside row actions (openclaw#119560) refactor(msteams): consolidate channel action target resolution (openclaw#119632) fix: tail context answers the current user message (openclaw#117364) fix(whatsapp): exercise descriptor-safe credential persistence (openclaw#119621) fix(diagnostics-otel): route OTLP endpoints by signal (openclaw#101655) refactor(skills): consolidate workshop transcript and record normalization (openclaw#119643) fix(video): harden DashScope task and media lifecycle (openclaw#117303) refactor(transcripts): consolidate persistence and export ownership (openclaw#119634) fix: preserve ClickClack discussion state contracts (openclaw#118851) fix(matrix): retire shared E2EE clients safely (openclaw#119570) refactor(cron): unify catch-up persistence and payload encoding (openclaw#119636) refactor(ui): centralize composer attachment and capability controls (openclaw#119650) refactor(daemon): consolidate managed service lifecycle ownership (openclaw#119647) fix(browser): honor explicit navigation timeouts across browser drivers (openclaw#119654) ...
…uote a short tool send (openclaw#118178) The forward substring check in isMessagingToolDuplicateNormalized treated any reply containing a prior message-tool send as a duplicate, with no length floor. A short interim update sent via the message tool then suppressed the entire final reply that restated it, and the user never received the answer. The reverse direction already carried a 0.5 length ratio floor. Apply the same floor to the forward direction so a reply is only deduped when the prior send covers at least half of it.
…a tool send isMessagingToolDuplicateNormalized calls text a duplicate when it contains a prior message-tool send that covers at least half of it (the 0.5 ratio from openclaw#118178). A reply that opens with the send and adds one short sentence clears that ratio, so the sentence never reaches the channel, even when it corrects the send: sent "Deployment finished." reply "Deployment finished. Actually it failed." -> dropped No length ratio separates "<sent> All good!" from "<sent> Actually it failed.", since both are the send plus a short tail. When the text starts with the prior send and the rest has a letter or digit, it is no longer a duplicate. A punctuation-only tail ("Deployment finished!!!") still goes through the ratio and stays a duplicate. A send quoted later in the text ('I sent the message: "..."') and the reverse direction are unchanged. The new branch can only return false, so nothing delivered before is dropped now. Deliberate test change: the "Checking the deploy logs now. All good!" row from openclaw#118178 flips from true to false. It is the same shape as the correction. Verified on the M4 at cecf47a + this change: sanitizeuserfacingtext.test.ts 124 passed; with messaging-dedupe.ts reverted to main, 3 failed (expected true to be false), 121 passed 94 test files that reference the dedupe helpers, their callers or messagingToolSentTexts: main 3400 passed, 1 skipped; this change 3403 passed, 1 skipped; the only per-file difference is the 3 rows above
… text only (#208260) ## Problem When the agent sent a message with the `message` tool and its final reply repeated that text inside new text, OpenClaw could drop the final reply. `isMessagingToolDuplicateNormalized` judged overlap by a 50% substring ratio after lowercasing and emoji stripping. This is a code judge on model output. It has already lost real answers (#118178: "the user never received the answer"), and each earlier fix added another ratio. Base-side Telegram proof (below): the user got the interim tool message, then `No answer was returned. Ask again if you still need one.` The answer was gone. ## Change - Final payload dedupe (`src/auto-reply/reply/reply-payloads-dedupe.ts`): keep only trimmed exact equality against sends on the matching route. That branch was already the first check. - Block streaming (`src/agents/embedded-agent-subscribe.stream-rendering.ts`): same trimmed exact equality against committed sent texts. - Deleted `isMessagingToolDuplicate`, `isMessagingToolDuplicateNormalized`, `hasTextBeyondSentTexts`, `MIN_DUPLICATE_TEXT_LENGTH`, `MIN_SUBSTRING_DUPLICATE_RATIO`, the `messagingToolSentTextsNormalized` run state that only fed them, and their ratio tests. - Unchanged: `resolveCurrentSourceMessagingToolPartial` (prefix equality), the `/btw` rendered-text equality, media dedupe. ## Impact (what the user sees) - A final reply that adds anything to a tool send is now delivered. - An exact repeat of a tool send on the same route is still suppressed. - Accepted edge cases (visible and recoverable, not silent loss): - A model that paraphrases its own tool send (case, punctuation, emoji changes included) shows the user both messages. - A send recorded without a route (for example `sessions_send` to another session) no longer suppresses an identical final in this chat. The user in this chat did not see that send, so delivering the final is correct. ## Decisions recorded - **`NO_REPLY` sentence in the `message` tool result: not added.** A same-chat send with `final` omitted or `true` already ends the turn structurally (`sourceReplyDeliveryState = "delivered"` suppresses later output, and the `final` parameter documents "A confirmed final source reply ends the turn"). A `final: false` send is progress, and the model is expected to answer after it, so telling it to end with `NO_REPLY` there would be wrong. No prompt, tool description or snapshot changes. - **Red test shape.** The brief's literal case (tool text as prefix plus a short result) was already delivered on base since #151921 (`hasTextBeyondSentTexts`). The red tests use the tool text embedded in a reply (`Sent "Deploy started, checking logs now". Logs clean.`), which base drops by the 50% ratio. ## Evidence Tests (red on base `d9cc195ce70f`, green on head): - `src/auto-reply/reply/agent-runner-payloads.test.ts`: embedded repeat on the matching route is delivered; unrouted exact repeat is delivered; routed exact repeat stays suppressed. - `src/agents/embedded-agent-subscribe.subscribe-embedded-agent-session.source-reply-suppression.test.ts`: streamed final that embeds the tool send is delivered. - Removed table rows in `followup-delivery.test.ts` and `agent-runner.misc.runreplyagent.test.ts` that asserted the unrouted ratio drop (they expected the "no answer" notice); the remaining unrouted rows cover the contract. Telegram E2E (Test Server, real user via TDLib, `--source-gateway`, scripted mock model over `openai-completions`: turn 1 calls `message` `{action: "send", message: "Deploy started, checking logs now", final: false}`, turn 2 replies `Sent "Deploy started, checking logs now". Logs clean.`): Base `d9cc195ce70f`: ``` user Deploy and report back. EXACTDEDUPE-BASE2 bot Deploy started, checking logs now bot Working / ✉️ Message running bot No answer was returned. Ask again if you still need one. ``` Head: ``` user Deploy and report back. EXACTDEDUPE-HEAD3 bot Deploy started, checking logs now bot Working / ✉️ Message bot Sent "Deploy started, checking logs now". Logs clean. ``` Local: `ocx test` on touched tests plus every test importing a changed source (58 files, green after the last code change); `pnpm check:changed` green except `dead export scan`, which flags unrelated files (`src/agents/command/types.ts`, `src/plugins/native-module-require.ts`, `ui/src/...`, `update.test-harness.ts`) that this PR does not touch. Co-authored-by: Ayaan Zaidi <[email protected]>
… text only (#208260) ## Problem When the agent sent a message with the `message` tool and its final reply repeated that text inside new text, OpenClaw could drop the final reply. `isMessagingToolDuplicateNormalized` judged overlap by a 50% substring ratio after lowercasing and emoji stripping. This is a code judge on model output. It has already lost real answers (#118178: "the user never received the answer"), and each earlier fix added another ratio. Base-side Telegram proof (below): the user got the interim tool message, then `No answer was returned. Ask again if you still need one.` The answer was gone. ## Change - Final payload dedupe (`src/auto-reply/reply/reply-payloads-dedupe.ts`): keep only trimmed exact equality against sends on the matching route. That branch was already the first check. - Block streaming (`src/agents/embedded-agent-subscribe.stream-rendering.ts`): same trimmed exact equality against committed sent texts. - Deleted `isMessagingToolDuplicate`, `isMessagingToolDuplicateNormalized`, `hasTextBeyondSentTexts`, `MIN_DUPLICATE_TEXT_LENGTH`, `MIN_SUBSTRING_DUPLICATE_RATIO`, the `messagingToolSentTextsNormalized` run state that only fed them, and their ratio tests. - Unchanged: `resolveCurrentSourceMessagingToolPartial` (prefix equality), the `/btw` rendered-text equality, media dedupe. ## Impact (what the user sees) - A final reply that adds anything to a tool send is now delivered. - An exact repeat of a tool send on the same route is still suppressed. - Accepted edge cases (visible and recoverable, not silent loss): - A model that paraphrases its own tool send (case, punctuation, emoji changes included) shows the user both messages. - A send recorded without a route (for example `sessions_send` to another session) no longer suppresses an identical final in this chat. The user in this chat did not see that send, so delivering the final is correct. ## Decisions recorded - **`NO_REPLY` sentence in the `message` tool result: not added.** A same-chat send with `final` omitted or `true` already ends the turn structurally (`sourceReplyDeliveryState = "delivered"` suppresses later output, and the `final` parameter documents "A confirmed final source reply ends the turn"). A `final: false` send is progress, and the model is expected to answer after it, so telling it to end with `NO_REPLY` there would be wrong. No prompt, tool description or snapshot changes. - **Red test shape.** The brief's literal case (tool text as prefix plus a short result) was already delivered on base since #151921 (`hasTextBeyondSentTexts`). The red tests use the tool text embedded in a reply (`Sent "Deploy started, checking logs now". Logs clean.`), which base drops by the 50% ratio. ## Evidence Tests (red on base `d9cc195ce70f`, green on head): - `src/auto-reply/reply/agent-runner-payloads.test.ts`: embedded repeat on the matching route is delivered; unrouted exact repeat is delivered; routed exact repeat stays suppressed. - `src/agents/embedded-agent-subscribe.subscribe-embedded-agent-session.source-reply-suppression.test.ts`: streamed final that embeds the tool send is delivered. - Removed table rows in `followup-delivery.test.ts` and `agent-runner.misc.runreplyagent.test.ts` that asserted the unrouted ratio drop (they expected the "no answer" notice); the remaining unrouted rows cover the contract. Telegram E2E (Test Server, real user via TDLib, `--source-gateway`, scripted mock model over `openai-completions`: turn 1 calls `message` `{action: "send", message: "Deploy started, checking logs now", final: false}`, turn 2 replies `Sent "Deploy started, checking logs now". Logs clean.`): Base `d9cc195ce70f`: ``` user Deploy and report back. EXACTDEDUPE-BASE2 bot Deploy started, checking logs now bot Working / ✉️ Message running bot No answer was returned. Ask again if you still need one. ``` Head: ``` user Deploy and report back. EXACTDEDUPE-HEAD3 bot Deploy started, checking logs now bot Working / ✉️ Message bot Sent "Deploy started, checking logs now". Logs clean. ``` Local: `ocx test` on touched tests plus every test importing a changed source (58 files, green after the last code change); `pnpm check:changed` green except `dead export scan`, which flags unrelated files (`src/agents/command/types.ts`, `src/plugins/native-module-require.ts`, `ui/src/...`, `update.test-harness.ts`) that this PR does not touch. Co-authored-by: Ayaan Zaidi <[email protected]> Follow-up scan: 34d4f8f improve: list Docker streams and flag unconfirmed cleanup in Doctor (#201292); 21786f6 refactor(ui): stop sending 28 additional unused labels to translators (#207982); 9cec330 refactor(workboard): group session tiles without rescanning each column (#207380); 16a2d4b refactor(ui): lowercase log search text only once (#207383). Other hits are not required by this focused beta.2 fix. (cherry picked from commit 5ba0e69) Co-authored-by: RomneyDa <[email protected]>
… text only (#208260) ## Problem When the agent sent a message with the `message` tool and its final reply repeated that text inside new text, OpenClaw could drop the final reply. `isMessagingToolDuplicateNormalized` judged overlap by a 50% substring ratio after lowercasing and emoji stripping. This is a code judge on model output. It has already lost real answers (#118178: "the user never received the answer"), and each earlier fix added another ratio. Base-side Telegram proof (below): the user got the interim tool message, then `No answer was returned. Ask again if you still need one.` The answer was gone. ## Change - Final payload dedupe (`src/auto-reply/reply/reply-payloads-dedupe.ts`): keep only trimmed exact equality against sends on the matching route. That branch was already the first check. - Block streaming (`src/agents/embedded-agent-subscribe.stream-rendering.ts`): same trimmed exact equality against committed sent texts. - Deleted `isMessagingToolDuplicate`, `isMessagingToolDuplicateNormalized`, `hasTextBeyondSentTexts`, `MIN_DUPLICATE_TEXT_LENGTH`, `MIN_SUBSTRING_DUPLICATE_RATIO`, the `messagingToolSentTextsNormalized` run state that only fed them, and their ratio tests. - Unchanged: `resolveCurrentSourceMessagingToolPartial` (prefix equality), the `/btw` rendered-text equality, media dedupe. ## Impact (what the user sees) - A final reply that adds anything to a tool send is now delivered. - An exact repeat of a tool send on the same route is still suppressed. - Accepted edge cases (visible and recoverable, not silent loss): - A model that paraphrases its own tool send (case, punctuation, emoji changes included) shows the user both messages. - A send recorded without a route (for example `sessions_send` to another session) no longer suppresses an identical final in this chat. The user in this chat did not see that send, so delivering the final is correct. ## Decisions recorded - **`NO_REPLY` sentence in the `message` tool result: not added.** A same-chat send with `final` omitted or `true` already ends the turn structurally (`sourceReplyDeliveryState = "delivered"` suppresses later output, and the `final` parameter documents "A confirmed final source reply ends the turn"). A `final: false` send is progress, and the model is expected to answer after it, so telling it to end with `NO_REPLY` there would be wrong. No prompt, tool description or snapshot changes. - **Red test shape.** The brief's literal case (tool text as prefix plus a short result) was already delivered on base since #151921 (`hasTextBeyondSentTexts`). The red tests use the tool text embedded in a reply (`Sent "Deploy started, checking logs now". Logs clean.`), which base drops by the 50% ratio. ## Evidence Tests (red on base `d9cc195ce70f`, green on head): - `src/auto-reply/reply/agent-runner-payloads.test.ts`: embedded repeat on the matching route is delivered; unrouted exact repeat is delivered; routed exact repeat stays suppressed. - `src/agents/embedded-agent-subscribe.subscribe-embedded-agent-session.source-reply-suppression.test.ts`: streamed final that embeds the tool send is delivered. - Removed table rows in `followup-delivery.test.ts` and `agent-runner.misc.runreplyagent.test.ts` that asserted the unrouted ratio drop (they expected the "no answer" notice); the remaining unrouted rows cover the contract. Telegram E2E (Test Server, real user via TDLib, `--source-gateway`, scripted mock model over `openai-completions`: turn 1 calls `message` `{action: "send", message: "Deploy started, checking logs now", final: false}`, turn 2 replies `Sent "Deploy started, checking logs now". Logs clean.`): Base `d9cc195ce70f`: ``` user Deploy and report back. EXACTDEDUPE-BASE2 bot Deploy started, checking logs now bot Working / ✉️ Message running bot No answer was returned. Ask again if you still need one. ``` Head: ``` user Deploy and report back. EXACTDEDUPE-HEAD3 bot Deploy started, checking logs now bot Working / ✉️ Message bot Sent "Deploy started, checking logs now". Logs clean. ``` Local: `ocx test` on touched tests plus every test importing a changed source (58 files, green after the last code change); `pnpm check:changed` green except `dead export scan`, which flags unrelated files (`src/agents/command/types.ts`, `src/plugins/native-module-require.ts`, `ui/src/...`, `update.test-harness.ts`) that this PR does not touch. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 5ba0e69) Follow-ups: 16a2d4b refactor(ui): lowercase log search text only once (#207383) [not selected for this narrow backport]; 21786f6 refactor(ui): stop sending 28 additional unused labels to translators (#207982) [not selected for this narrow backport]; 34d4f8f improve: list Docker streams and flag unconfirmed cleanup in Doctor (#201292) [not selected for this narrow backport]; 9cec330 refactor(workboard): group session tiles without rescanning each column (#207380) [not selected for this narrow backport] Co-authored-by: RomneyDa <[email protected]>
… text only (openclaw#208260) ## Problem When the agent sent a message with the `message` tool and its final reply repeated that text inside new text, OpenClaw could drop the final reply. `isMessagingToolDuplicateNormalized` judged overlap by a 50% substring ratio after lowercasing and emoji stripping. This is a code judge on model output. It has already lost real answers (openclaw#118178: "the user never received the answer"), and each earlier fix added another ratio. Base-side Telegram proof (below): the user got the interim tool message, then `No answer was returned. Ask again if you still need one.` The answer was gone. ## Change - Final payload dedupe (`src/auto-reply/reply/reply-payloads-dedupe.ts`): keep only trimmed exact equality against sends on the matching route. That branch was already the first check. - Block streaming (`src/agents/embedded-agent-subscribe.stream-rendering.ts`): same trimmed exact equality against committed sent texts. - Deleted `isMessagingToolDuplicate`, `isMessagingToolDuplicateNormalized`, `hasTextBeyondSentTexts`, `MIN_DUPLICATE_TEXT_LENGTH`, `MIN_SUBSTRING_DUPLICATE_RATIO`, the `messagingToolSentTextsNormalized` run state that only fed them, and their ratio tests. - Unchanged: `resolveCurrentSourceMessagingToolPartial` (prefix equality), the `/btw` rendered-text equality, media dedupe. ## Impact (what the user sees) - A final reply that adds anything to a tool send is now delivered. - An exact repeat of a tool send on the same route is still suppressed. - Accepted edge cases (visible and recoverable, not silent loss): - A model that paraphrases its own tool send (case, punctuation, emoji changes included) shows the user both messages. - A send recorded without a route (for example `sessions_send` to another session) no longer suppresses an identical final in this chat. The user in this chat did not see that send, so delivering the final is correct. ## Decisions recorded - **`NO_REPLY` sentence in the `message` tool result: not added.** A same-chat send with `final` omitted or `true` already ends the turn structurally (`sourceReplyDeliveryState = "delivered"` suppresses later output, and the `final` parameter documents "A confirmed final source reply ends the turn"). A `final: false` send is progress, and the model is expected to answer after it, so telling it to end with `NO_REPLY` there would be wrong. No prompt, tool description or snapshot changes. - **Red test shape.** The brief's literal case (tool text as prefix plus a short result) was already delivered on base since openclaw#151921 (`hasTextBeyondSentTexts`). The red tests use the tool text embedded in a reply (`Sent "Deploy started, checking logs now". Logs clean.`), which base drops by the 50% ratio. ## Evidence Tests (red on base `98bb8cc00cc9`, green on head): - `src/auto-reply/reply/agent-runner-payloads.test.ts`: embedded repeat on the matching route is delivered; unrouted exact repeat is delivered; routed exact repeat stays suppressed. - `src/agents/embedded-agent-subscribe.subscribe-embedded-agent-session.source-reply-suppression.test.ts`: streamed final that embeds the tool send is delivered. - Removed table rows in `followup-delivery.test.ts` and `agent-runner.misc.runreplyagent.test.ts` that asserted the unrouted ratio drop (they expected the "no answer" notice); the remaining unrouted rows cover the contract. Telegram E2E (Test Server, real user via TDLib, `--source-gateway`, scripted mock model over `openai-completions`: turn 1 calls `message` `{action: "send", message: "Deploy started, checking logs now", final: false}`, turn 2 replies `Sent "Deploy started, checking logs now". Logs clean.`): Base `98bb8cc00cc9`: ``` user Deploy and report back. EXACTDEDUPE-BASE2 bot Deploy started, checking logs now bot Working / ✉️ Message running bot No answer was returned. Ask again if you still need one. ``` Head: ``` user Deploy and report back. EXACTDEDUPE-HEAD3 bot Deploy started, checking logs now bot Working / ✉️ Message bot Sent "Deploy started, checking logs now". Logs clean. ``` Local: `ocx test` on touched tests plus every test importing a changed source (58 files, green after the last code change); `pnpm check:changed` green except `dead export scan`, which flags unrelated files (`src/agents/command/types.ts`, `src/plugins/native-module-require.ts`, `ui/src/...`, `update.test-harness.ts`) that this PR does not touch. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
When an agent posts a short interim update through the message tool (for example "Checking the deploy logs now.") and then restates that line at the start of its final answer, the messaging dedupe filter classifies the entire final reply as a duplicate and drops it. With block streaming off (the default), the final payload set is the only delivery of the answer, so the user receives the 29 character interim line and never sees the full reply. The text survives only in the session transcript, which a channel-only user cannot access.
Root cause is in
src/agents/embedded-agent-helpers/messaging-dedupe.ts. The forward substring check treats any reply that contains a prior tool send as a duplicate with no length floor:The reverse direction already carries a deliberate 0.5 length ratio floor, so proportionality was reasoned about and then omitted in the forward direction. A 29 character send suppresses a 316 character reply at a 0.09 overlap ratio.
Why This Change Was Made
Apply the same 0.5 ratio floor to the forward direction, so a reply is deduped only when the prior send covers at least half of it:
This is the right boundary because every dedupe consumer routes through
isMessagingToolDuplicateNormalized: the final payload filter (src/auto-reply/reply/reply-payloads-dedupe.tsviaagent-runner-payloads.ts), the follow-up delivery filter (src/auto-reply/reply/followup-delivery-payloads.ts), and both streamed chunk suppression sites (src/agents/embedded-agent-subscribe.ts,src/agents/embedded-agent-subscribe.handlers.messages.ts). One fix in the shared predicate covers all of them; no sibling call site needs its own change.Intended dedupe behavior is preserved: exact restatements (ratio 1), narrations like
I sent the message: "..."(ratio 0.58, pinned by the existing test), and short suffix additions such as the sent text plus "All good!" (ratio 0.74) are still suppressed. Only replies with substantial content beyond the tool send are now delivered.Closest prior art: #97513 (closed, trailing acks after tool sends) and #54061 (closed, whole-turn inline text suppression). Neither touches the substring direction asymmetry.
User Impact
Final answers on Telegram, WhatsApp, Signal, Slack, and every other channel are no longer silently withheld when they open with or quote a short interim update the agent already sent. This was a silent failure: the user saw only the interim line with no indication anything was dropped.
Evidence
Driving the real reply payload assembly (
buildReplyPayloadsinsrc/auto-reply/reply/agent-runner-payloads.ts, the production function the agent runner uses to build the final delivery set) with a Telegram routed turn: one 316 character final assistant reply that opens with a 29 character message-tool send recorded for the same route. No seams were replaced; the route matching, dedupe decision, and filtering are the production code paths.Before (pristine main a8b114b):
After (this patch, identical inputs):
Verification:
src/agents/embedded-agent-helpers.sanitizeuserfacingtext.test.ts: the long reply quoting a short send must be delivered, and a short restatement plus "All good!" must still dedupe. The suite fails on pristine main (1 failed, 113 passed) and passes with the patch (114 passed).src/auto-reply/reply/agent-runner-payloads.test.ts,src/auto-reply/reply/reply-payloads.test.ts,src/agents/embedded-agent-subscribe.handlers.messages.test.ts.scripts/run-oxlint.mjsandoxfmt --checkclean on both changed files.