Skip to content

[Bug]: Telegram final replies with media ignore configured mediaMaxMb in outbound delivery path #46023

Description

@Designdocs

Bug type

Crash (process/app exits or hangs)

Summary

Telegram final replies that include media do not honor the configured mediaMaxMb because the outbound delivery path does not propagate mediaMaxBytes into deliverMediaReply(...) / loadWebMedia(...).

Steps to reproduce

  1. Install OpenClaw via global npm on Linux.
  2. Configure a Telegram account/channel with a larger outbound media limit, for example channels.telegram.mediaMaxMb: 50.
  3. Trigger a final assistant reply that includes outbound media via mediaUrl or mediaUrls.
  4. Use media whose size is above the lower fallback/default path but intended to be allowed by the configured Telegram limit.
  5. Observe gateway logs during final reply delivery.

Expected behavior

Telegram outbound final replies with media should respect the configured mediaMaxMb / mediaMaxBytes limit and send successfully when the media is within that configured limit.

Actual behavior

The final Telegram reply fails during outbound media delivery instead of honoring the configured limit. Investigation of the built output shows that the Telegram outbound path computes mediaMaxBytes, but the value is not threaded through the final reply delivery chain into deliverMediaReply(...) and then into loadWebMedia(...).

Relevant evidence from the built distribution:

const mediaMaxBytes = (opts.mediaMaxMb ?? telegramCfg.mediaMaxMb ?? 100) * 1024 * 1024;

deliverReplies(...) currently calls deliverMediaReply(...) without passing mediaMaxBytes, and deliverMediaReply(...) loads media with:

const media = await loadWebMedia(
  mediaUrl,
  buildOutboundMediaLoadOptions({ mediaLocalRoots: params.mediaLocalRoots })
);

So the configured Telegram media limit exists, but is not consistently applied in the outbound final media reply path.

OpenClaw version

2026.3.11

Operating system

Ubuntu 24

Install method

npm global

Model

codex 5.4

Provider / routing chain

openclaw -> configured provider/router -> Telegram outbound delivery

Config file / key location

channels.telegram.mediaMaxMb

Additional provider/model setup details

This does not appear to be provider-specific. The failure is in the Telegram outbound delivery layer after reply generation, specifically in the final reply path that handles mediaUrl / mediaUrls.

The problematic path is:

dispatchReplyWithBufferedBlockDispatcher(...)
-> deliver(...)
-> sendPayload(...)
-> deliverReplies(params)
-> deliverMediaReply(...)
-> loadWebMedia(...)

The Telegram channel code already computes mediaMaxBytes, but it is not propagated through that outbound media delivery chain.

Logs, screenshots, and evidence

Relevant code evidence from the built distribution:

// mediaMaxBytes is computed for Telegram
const mediaMaxBytes = (opts.mediaMaxMb ?? telegramCfg.mediaMaxMb ?? 100) * 1024 * 1024;
// deliverReplies(...) does not pass mediaMaxBytes into deliverMediaReply(...)
else firstDeliveredMessageId = await deliverMediaReply({
  reply,
  mediaList,
  bot: params.bot,
  chatId: params.chatId,
  runtime: params.runtime,
  thread: params.thread,
  tableMode: params.tableMode,
  mediaLocalRoots: params.mediaLocalRoots,
  chunkText,
  onVoiceRecording: params.onVoiceRecording,
  linkPreview: params.linkPreview,
  replyQuoteText: params.replyQuoteText,
  replyMarkup,
  replyToId,
  replyToMode: params.replyToMode,
  progress
});
// deliverMediaReply(...) loads outbound media without maxBytes
const media = await loadWebMedia(
  mediaUrl,
  buildOutboundMediaLoadOptions({ mediaLocalRoots: params.mediaLocalRoots })
);

Relevant function locations from the tested build:

deliverReplies(...)      : model-auth-Ca9MYDEo.js:155946
deliverMediaReply(...)   : around 155740-155930
Telegram reply dispatcher: around 159300-159570

This strongly suggests the configured Telegram media cap is computed but not actually enforced in the outbound final media reply path.

Impact and severity

Affected: Telegram users/channels sending final replies with outbound media
Severity: High (blocks or breaks media replies despite valid configuration)
Frequency: Consistent for the affected code path
Consequence: Final Telegram replies with media may fail unexpectedly, causing missed media responses and requiring local patching

Additional information

This appears to be a narrow parameter-threading bug, not a Telegram API parsing/config bug.

  1. A minimal fix would be to propagate mediaMaxBytes through the outbound Telegram delivery path:
  2. add mediaMaxBytes to deliveryBaseOptions / deliverReplies(...) params
  3. pass mediaMaxBytes: params.mediaMaxBytes into deliverMediaReply(...)

use it in deliverMediaReply(...) when calling loadWebMedia(...), for example:

const media = await loadWebMedia(
  mediaUrl,
  buildOutboundMediaLoadOptions({
    mediaLocalRoots: params.mediaLocalRoots,
    maxBytes: params.mediaMaxBytes
  })
);

This would make the Telegram outbound final media reply path consistent with the existing Telegram media limit configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:crashProcess/app exits unexpectedly or hangsclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions