Skip to content

fix(telegram): honor outbound media max bytes#83478

Merged
RomneyDa merged 1 commit into
openclaw:mainfrom
luoyanglang:wolf/telegram-outbound-media-maxbytes
May 22, 2026
Merged

fix(telegram): honor outbound media max bytes#83478
RomneyDa merged 1 commit into
openclaw:mainfrom
luoyanglang:wolf/telegram-outbound-media-maxbytes

Conversation

@luoyanglang

@luoyanglang luoyanglang commented May 18, 2026

Copy link
Copy Markdown
Contributor

Telegram final replies with media above the default cap can fail even when users configured a larger channels.telegram.mediaMaxMb limit.

Fixes #46023

Affected surface

  • extensions/telegram/src/bot-core.ts
  • extensions/telegram/src/bot-message-dispatch.ts
  • extensions/telegram/src/bot-native-commands.ts
  • extensions/telegram/src/bot/delivery.replies.ts

Scope

This is a narrow parameter-threading fix. It carries the existing Telegram media byte cap into final and native reply delivery, then reuses buildOutboundMediaLoadOptions({ maxBytes }) when outbound media is loaded. No new config, policy, or media-limit strategy is introduced.

Approximate scope: 52 inserted lines / 4 removed lines including regression tests.

Real behavior proof

  • Behavior or issue addressed: Telegram final/native replies with media now thread the configured 50 MiB mediaMaxMb cap into outbound media loading instead of falling back to the default video cap.

  • Real environment tested: Local Linux executor, branch wolf/telegram-outbound-media-maxbytes, head 935da229b9, Node.js v22.22.2; real Telegram Bot API delivery through sendVideo into Telegram Desktop.

  • Exact steps or command run after this patch:

    1. Started a temporary local Node/tsx harness outside the repository.
    2. Imported OpenClaw source deliverReplies from extensions/telegram/src/bot/delivery.replies.ts.
    3. Exercised the real path deliverReplies -> deliverMediaReply -> loadWebMedia -> Telegram Bot API sendVideo.
    4. Served a valid 35,462,055-byte MP4 from a local HTTP server and ran the before case without mediaMaxBytes.
    5. Re-ran the same delivery with mediaMaxBytes = 52428800.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): Telegram Desktop visible proof is attached at https://github.com/user-attachments/assets/ed6790f0-d4b3-431d-b333-a2bc43d9e06c and also referenced from fix(telegram): honor outbound media max bytes #83478 (comment).

    Redacted local live run log:

    [server] local_http=started url=<local-http-url>
    [before] start file_size=35462055 maxBytes=<default> url=<local-http-url>
    [before] loadWebMedia input url=<local-http-url> maxBytes=<default>
    [before] result=error error=Media exceeds 16MB limit (got 33.82MB)
    [after] start file_size=35462055 maxBytes=52428800 url=<local-http-url>
    [after] loadWebMedia input url=<local-http-url> maxBytes=52428800
    [telegram] method=sendVideo chat_id=<redacted-chat-id> status=pending
    [telegram] method=sendVideo http_status=200 message_id=2
    [after] result=success delivered=true
    [server] local_http=stopped
    
  • Observed result after fix: Without mediaMaxBytes, the same 35,462,055-byte MP4 fails in OpenClaw media loading with the default 16 MiB video cap. With mediaMaxBytes = 52428800, loadWebMedia accepts the media, Telegram Bot API sendVideo returns HTTP 200, and Telegram Desktop shows the delivered media.

  • What was not tested: This live proof covers the Telegram video reply path on a local Linux executor with real Telegram Bot API delivery; macOS/iOS apps and non-Telegram channels are outside this PR.

  • Before evidence (optional but encouraged): The before case in the same live harness failed before Telegram delivery with Media exceeds 16MB limit (got 33.82MB).

Local regression/changed-check output:

$ pnpm test extensions/telegram/src/bot/delivery.test.ts extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/bot-native-commands.test.ts
 Test Files  3 passed (3)
      Tests  138 passed (138)

$ pnpm check:changed --base origin/main
check:changed completed changed extension lanes, extension typecheck, extension test typecheck, oxlint, media helper guard, runtime sidecar loader guard, and import cycle check with no failures.

$ git diff --check
<no output>

$ gitleaks protect --staged --redact
no leaks found

Coverage note

ClawSweeper confirmed in issue #46023 that current main still has this gap: Telegram computes mediaMaxBytes, but normal final replies and native-command replies do not thread a media cap into deliverReplies, deliverMediaReply, or loadWebMedia. I also checked open PR coverage before starting; no open PR covered #46023, Telegram mediaMaxMb, or deliverReplies mediaMaxBytes.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 18, 2026
@clawsweeper

clawsweeper Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The PR passes the configured Telegram media byte cap through final and native reply delivery so outbound media loading receives maxBytes, with targeted regression tests.

Reproducibility: yes. Current main documents the outbound cap and computes mediaMaxBytes, but the final/native reply media loader path does not receive it; the PR also includes before/after live Telegram proof for an oversized-but-configured media reply.

PR rating
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Summary: Focused patch with targeted tests and convincing live Telegram proof; remaining review is ordinary maintainer and CI gating.

What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Real behavior proof
Sufficient (logs): The PR body and linked comment include redacted live Telegram Bot API output plus a Telegram Desktop screenshot showing after-fix media delivery.

Risk before merge

Maintainer options:

  1. Decide the mitigation before merge
    Land this focused parameter-threading fix after normal CI and branch freshness gates, preserving both maxBytes and any proxy transport option plumbing if the related media-proxy PR lands first.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge
No repair lane is needed; the PR has a focused patch, sufficient real behavior proof, and no actionable review findings.

Security
Cleared: The diff only threads an existing numeric Telegram media limit through delivery and tests; it adds no dependencies, scripts, secrets handling, or new code execution surface.

Review details

Best possible solution:

Land this focused parameter-threading fix after normal CI and branch freshness gates, preserving both maxBytes and any proxy transport option plumbing if the related media-proxy PR lands first.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main documents the outbound cap and computes mediaMaxBytes, but the final/native reply media loader path does not receive it; the PR also includes before/after live Telegram proof for an oversized-but-configured media reply.

Is this the best way to solve the issue?

Yes. The PR reuses the existing config and buildOutboundMediaLoadOptions({ maxBytes }) contract without adding new policy, config, or a competing media-limit path.

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body and linked comment include redacted live Telegram Bot API output plus a Telegram Desktop screenshot showing after-fix media delivery.
  • add rating: 🦞 diamond lobster: Current PR rating is 🦞 diamond lobster because proof is 🦞 diamond lobster, patch quality is 🦞 diamond lobster, and Focused patch with targeted tests and convincing live Telegram proof; remaining review is ordinary maintainer and CI gating.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body and linked comment include redacted live Telegram Bot API output plus a Telegram Desktop screenshot showing after-fix media delivery.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a focused Telegram delivery bug fix for configured media replies with limited channel-specific blast radius.
  • rating: 🦞 diamond lobster: Current PR rating is 🦞 diamond lobster because proof is 🦞 diamond lobster, patch quality is 🦞 diamond lobster, and Focused patch with targeted tests and convincing live Telegram proof; remaining review is ordinary maintainer and CI gating.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body and linked comment include redacted live Telegram Bot API output plus a Telegram Desktop screenshot showing after-fix media delivery.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and linked comment include redacted live Telegram Bot API output plus a Telegram Desktop screenshot showing after-fix media delivery.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. This PR changes visible Telegram media reply delivery, which is demonstrable in a short Telegram Desktop proof.

What I checked:

Likely related people:

  • vincentkoc: Authored the earlier Telegram/Discord outbound mediaMaxMb send-path fix and later injected the media loader seam in Telegram reply delivery tests, which is the seam this PR extends. (role: feature-history contributor; confidence: high; commits: 9c1786bdd6cc, 79d7fdce932b; files: extensions/telegram/src/send.ts, extensions/telegram/src/bot/delivery.replies.ts, extensions/telegram/src/bot/delivery.test.ts)
  • steipete: Shortlog shows the most commits across the central Telegram delivery files, including earlier reply delivery refactors that carried through the current extension path. (role: heavy area contributor; confidence: medium; commits: 5197171d7abd, 1d99401b8bc5, 4b125762f6bb; files: extensions/telegram/src/bot/delivery.replies.ts, extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-core.ts)
  • obviyus: Current-main blame and log show the most recent broad touch of the central Telegram files, although the commit title is unrelated and the history is noisy after file recreation. (role: recent area contributor; confidence: medium; commits: ac28341ebfcc; files: extensions/telegram/src/bot/delivery.replies.ts, extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-native-commands.ts)
  • jalehman: Authored a recent native command delivery change touching bot-native-commands.ts, which is one of the reply paths this PR threads through. (role: adjacent native-command contributor; confidence: medium; commits: ed8d5b379791; files: extensions/telegram/src/bot-native-commands.ts, extensions/telegram/src/bot-native-commands.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 110042d840bb.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 18, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. labels May 18, 2026
@openclaw openclaw deleted a comment from openclaw-mantis Bot May 18, 2026
@luoyanglang

Copy link
Copy Markdown
Contributor Author

Telegram Desktop visible proof for the local live Telegram run. The bot chat shows the media delivered by message_id=2 from the after case.
openclaw test

@luoyanglang

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 20, 2026
@luoyanglang

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🌱 uncommon Sunspot Review Wisp

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🌱 uncommon.
Trait: watches the merge queue.
Image traits: location flaky test forest; accessory proof snapshot camera; palette seafoam, black, and opal; mood calm; pose stepping out of a freshly hatched shell; shell woven fiber shell; lighting warm desk-lamp glow; background miniature CI buoys.
Share on X: post this hatch
Copy: My PR egg hatched a 🌱 uncommon Sunspot Review Wisp in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@RomneyDa
RomneyDa merged commit f2d4f93 into openclaw:main May 22, 2026
206 of 231 checks passed
@luoyanglang
luoyanglang deleted the wolf/telegram-outbound-media-maxbytes branch May 23, 2026 11:20
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants