#5080: fix(reply): fix duplicate block replies by unblocking coalesced payloads
Cluster:
Telegram Message Handling Fixes
## Summary
This PR fixes a regression in which coalesced block replies were being incorrectly blocked by the duplicate detection logic introduced to prevent double-sending.
The fix ensures that payloads flushed from the `block-reply-coalescer` bypass the seen check in
Sendpayload.
These payloads are marked as seen when they first enter the coalescer queue, which makes it safe.
## Related Issue
Fixes #3549
## Changes
- `src/auto-reply/reply/block-reply-pipeline.ts`
- Updated `createBlockReplyPipeline` to accept a `skipSeen` flag in `sendPayload`
- Passed `true` for `skipSeen` when flushing payloads from the coalescer
## Testing
```bash
npx vitest run src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.signals-typing-block-replies.test.ts
RUN v4.0.18 /home/yassineamjad/moltbot
✓ src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.signals-typing-block-replies.test.ts (4 tests) 39ms
✓ runReplyAgent typing (heartbeat) (4)
✓ signals typing on block replies 22ms
✓ signals typing on tool results 4ms
✓ skips typing for silent tool results 1ms
✓ announces auto-compaction in verbose mode and tracks count 9ms
Test Files 1 passed (1)
Tests 4 passed (4)
Start at 02:23:32
Duration 3.51s (transform 1.62s, setup 1.70s, import 1.56s, tests 39ms, environment 0ms)
```
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adjusts the block-reply pipeline’s de-duplication behavior for coalesced block replies. Specifically, payloads that are enqueued into the coalescer are now marked as `seen` at enqueue time, and when the coalescer flushes it calls `sendPayload` with a flag to bypass the `seenKeys` check so the flushed payload can still be delivered.
This fits into the existing pipeline design that tracks `seenKeys`/`pendingKeys`/`sentKeys` to prevent double-sends while preserving ordering via `sendChain` and allowing coalescing/buffering stages to batch replies.
<h3>Confidence Score: 4/5</h3>
- This PR looks safe to merge with low functional risk.
- The change is narrowly scoped to the block-reply pipeline and aligns with the stated intent: mark coalesced payloads as seen at enqueue and bypass the seen-check on flush. I did not find a clear functional regression in the new logic from the diff; the main concern is maintainability/readability of the new flag, which could be misused later.
- src/auto-reply/reply/block-reply-pipeline.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#14216: fix(messaging): check both pipeline and direct keys for reply deduping
by F1xTrack · 2026-02-11
82.9%
#12180: fix: merge multi-block assistant texts into single reply
by 1960697431 · 2026-02-08
79.6%
#8205: fix: flush followup messages incrementally
by hanxiao · 2026-02-03
77.9%
#9171: Fix: Route tool result deliveries through BlockReplyPipeline for pr...
by vishaltandale00 · 2026-02-04
77.3%
#17316: fix: ack reaction not removed when block streaming is enabled (Tele...
by czmathew · 2026-02-15
76.2%
#15996: fix(agents): messages arrive out of order — tool output beats narra...
by yinghaosang · 2026-02-14
75.3%
#7758: fix: prevent opts closure reuse across messages in shared followup ...
by Alexwang-sol · 2026-02-03
75.2%
#17953: fix(telegram): prevent silent message loss and duplicate messages i...
by zuyan9 · 2026-02-16
74.6%
#7719: fix(slack): thread replies with @mentions dropped in requireMention...
by SocialNerd42069 · 2026-02-03
74.5%
#14977: fix(telegram): remove ack reaction after block-streamed replies
by Diaspar4u · 2026-02-12
73.9%