openclaw - 💡(How to fix) Fix Bug Report: Duplicate Voice Messages in Telegram When Using Inline MEDIA: Directives [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#81464Fetched 2026-05-14 03:31:51
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
2
Author
Timeline (top)
mentioned ×3subscribed ×3closed ×1commented ×1

When an assistant response contains an inline MEDIA: directive pointing to a local .ogg audio file (Opus/24000Hz, suitable for voice messages), the Telegram channel delivers two identical voice messages instead of one. The duplication is internal to OpenClaw's delivery pipeline, not a Telegram API or client-side issue.

Root Cause

Suspected Root Cause

The merged Telegram outbound adapter (resolveChatChannelOutbound in core-DAU5xPEB.js) registers both a sendPayload handler and a sendMedia/sendText handler. Under certain conditions (media-only payload with audioAsVoice), OpenClaw may invoke both paths for the same outbound payload, causing the Telegram Bot API to receive two sendVoice requests.

Fix Action

Workaround

Avoid inline MEDIA: directives for local audio files targeting Telegram voice messages. Instead, send the voice message directly via the Telegram Bot API (sendVoice) outside of OpenClaw's inline media pipeline, or use a channel-native method that does not rely on the MEDIA: parser.

Code Example

MEDIA:/tmp/test_voice.ogg

---

{
  "text": "MEDIA:/tmp/test_voice.ogg",
  "audioAsVoice": true
}

---

curl -F "voice=@/tmp/test_voice.ogg" \
       https://api.telegram.org/bot<TOKEN>/sendVoice \
       -F "chat_id=<CHAT_ID>"
RAW_BUFFERClick to expand / collapse

Bug Report: Duplicate Voice Messages in Telegram When Using Inline MEDIA: Directives

Summary

When an assistant response contains an inline MEDIA: directive pointing to a local .ogg audio file (Opus/24000Hz, suitable for voice messages), the Telegram channel delivers two identical voice messages instead of one. The duplication is internal to OpenClaw's delivery pipeline, not a Telegram API or client-side issue.

Environment

  • OpenClaw Version: Latest stable (as of 2026-05-13)
  • Channel: Telegram (Bot API)
  • Runtime: Node.js v22.22.2, Linux x64
  • Audio Format: OGG Opus, 24kHz, mono, produced via ffmpeg (libopus)

Steps to Reproduce

  1. Generate or place a valid OGG Opus audio file locally (e.g., /tmp/test_voice.ogg).
  2. In an assistant turn, emit a reply with only the inline media directive and no other text:
    MEDIA:/tmp/test_voice.ogg
  3. Observe the delivered message(s) in the Telegram chat.

Minimal Reproduction Payload

An assistant turn that returns a payload equivalent to:

{
  "text": "MEDIA:/tmp/test_voice.ogg",
  "audioAsVoice": true
}

Expected Behavior

A single voice message is delivered to the Telegram chat.

Actual Behavior

Two identical voice messages are delivered consecutively. The user confirmed the duplication even when the message text is completely empty and only the inline MEDIA: directive is present.

Isolation Evidence

1. Empty-Text Test

  • Test: Sent a payload with text: "" and only the MEDIA: reference.
  • Result: Duplication still occurs. This rules out text-chunking / sendChunkedText as the cause.

2. Direct Telegram API Test

  • Test: Sent the exact same .ogg file via raw Telegram Bot API:
    curl -F "voice=@/tmp/test_voice.ogg" \
         https://api.telegram.org/bot<TOKEN>/sendVoice \
         -F "chat_id=<CHAT_ID>"
  • Result: Only one voice message arrived.
  • Conclusion: The duplication is introduced by OpenClaw, not by Telegram, the Bot API, or the Telegram client.

3. TTS Auto-Generation Ruled Out

  • Chat-level TTS state is disabled. The last TTS attempt was >70,000 seconds ago.
  • No TTS synthesis is triggered automatically in this conversation.

4. Process Deduplication

  • Only a single OpenClaw Gateway process is running (/usr/lib/node_modules/openclaw/dist/index.js gateway).
  • No duplicate gateway instances or conflicting systemd services.

Code-Path Observations

Parsing Layer (parse-B76mhGNs.js)

  • splitMediaFromOutput() correctly extracts the MEDIA: token.
  • mergeMediaUrls() deduplicates media URLs using a Set.
  • No duplicate URLs are present in the parsed payload.

Delivery Planning (deliver-B1inyF3M.js)

  • createOutboundPayloadPlanEntry() produces a single plan entry with:
    • mediaUrls: ["/tmp/test_voice.ogg"]
    • mediaUrl: "/tmp/test_voice.ogg"
    • audioAsVoice: true
  • No duplicate plan entries are generated.

Telegram Adapter (bot-Cz07SkTy.js, send-bPHq8YyA.js, delivery-BecZ5PlV.js)

  • The adapter exposes two outbound paths:
    1. base.sendPayloadsendTelegramPayloadMessagessendPayloadMediaSequenceOrFallback
    2. attachedResults.sendMedia / sendTextsendTelegramOutboundsendMessageTelegram
  • In deliverOutboundPayloadsCore() (deliver-B1inyF3M.js), when audioAsVoice === true, the payload is routed through handler.sendPayload. When false, it goes through handler.sendMedia.
  • Hypothesis: Both adapter paths may be firing for the same assistant reply, or the dispatch layer (dispatch-DHFZoYxZ.js) emits the final payload twice under specific media-only conditions.

Retry Policy (retry-policy-DlAQ40hs.js)

  • Retries are only triggered on pre-connect errors or rate limits (429).
  • No retry occurs after a successful sendVoice call.

Suspected Root Cause

The merged Telegram outbound adapter (resolveChatChannelOutbound in core-DAU5xPEB.js) registers both a sendPayload handler and a sendMedia/sendText handler. Under certain conditions (media-only payload with audioAsVoice), OpenClaw may invoke both paths for the same outbound payload, causing the Telegram Bot API to receive two sendVoice requests.

Workaround

Avoid inline MEDIA: directives for local audio files targeting Telegram voice messages. Instead, send the voice message directly via the Telegram Bot API (sendVoice) outside of OpenClaw's inline media pipeline, or use a channel-native method that does not rely on the MEDIA: parser.

Suggested Fix Areas for Maintainers

  1. Adapter Routing: Audit deliverOutboundPayloadsCore in deliver-B1inyF3M.js to ensure that media payloads with audioAsVoice are not also dispatched through sendMedia/sendText fallback paths.
  2. Dispatch Deduplication: Add an idempotency check or delivery-state guard in dispatch-DHFZoYxZ.js before calling sendFinalPayload for media-only replies.
  3. Logging: There is currently no accessible runtime log for outbound HTTP requests to Telegram. Adding a verbose log line before each bot.api.sendVoice call would make this class of bugs trivial to diagnose.

Additional Notes

  • The inline MEDIA: syntax works correctly for images and other media types; the duplication appears specific to audio/voice payloads where audioAsVoice is involved.
  • The issue persists across message types (DM, direct chat) and is not related to group/thread routing.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug Report: Duplicate Voice Messages in Telegram When Using Inline MEDIA: Directives [1 comments, 2 participants]