fix(telegram): prevent duplicate equivalent payload sends per turn#30478
fix(telegram): prevent duplicate equivalent payload sends per turn#30478Sid-Qin wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Prevent duplicate Telegram sends when dispatcher emits semantically identical payloads in the same turn by keying delivered text/media content and skipping repeats, including voice-vs-audio flag drift for the same attachment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 687ce1adbf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return JSON.stringify({ | ||
| text, | ||
| mediaList, | ||
| replyToId: payload.replyToId ?? null, |
There was a problem hiding this comment.
Include button metadata in payload dedupe key
buildDeliveredPayloadKey only hashes text, mediaList, and replyToId, so two payloads with different channelData.telegram.buttons are treated as duplicates and the latter send is skipped. In Telegram delivery, those buttons are part of the outbound reply_markup, so this can drop intended inline keyboards when the same text/media is resent with updated actions in the same dispatch turn, leaving users without the expected controls.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR adds per-dispatch deduplication to prevent semantically identical Telegram payloads from being sent multiple times within the same turn. The implementation introduces a Key changes:
Confidence Score: 5/5
Last reviewed commit: 687ce1a |
Add channel-agnostic outbound message deduplication to fix duplicate message delivery across Telegram, WhatsApp, and all other channels. Layer 1 (Cross-turn TTL dedup): Process-level 30s TTL cache skips identical payloads recently sent to the same recipient — covers queue race conditions, cron announce repeats, and tool execution races. Layer 2 (Text self-duplication): Normalization step detects and fixes paragraph-level and full-text repetition before delivery — covers BlueBubbles streaming concatenation bug. Key design: - channelData fingerprint (sorted JSON) included in dedup key - Resolved replyToId (payload-level ?? dispatch-level fallback) - JSON.stringify array key format to prevent delimiter collisions - Only registers after successful delivery (failed sends can retry) Fixes openclaw#30316, openclaw#25192 Supersedes openclaw#30478
Summary
audioAsVoicediffers for the same attachmentTest plan
pnpm exec vitest run src/telegram/bot-message-dispatch.test.tsdedupes equivalent media finals within one dispatch turnFixes #30316