openclaw - 💡(How to fix) Fix [Feature]: Telegram — expose mediaGroupTimeoutMs / mediaGroupFlushMs as a user-facing config key (follow-up to #1811) [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#76149Fetched 2026-05-03 04:41:47
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
2
Author
Timeline (top)
commented ×1cross-referenced ×1mentioned ×1subscribed ×1

Fix Action

Fix / Workaround

Workarounds today

  • Adding a caption sometimes routes the message through paths that pick up the inbound debouncer (less reliable for media-only sends).
  • Forking the package to patch the constant.

cc #1811, related to #39343 (the Telegram half of that broader request would be resolved by this).

Code Example

const mediaGroupTimeoutMs = typeof opts.testTimings?.mediaGroupFlushMs === "number"
  && Number.isFinite(opts.testTimings.mediaGroupFlushMs)
    ? Math.max(10, Math.floor(opts.testTimings.mediaGroupFlushMs))
    : 500;

---

if (!hasDebounceableText) return false;
return entry.allMedia.length === 0;

---

{
  "channels": {
    "telegram": {
      "mediaGroupFlushMs": 1500   // optional, default remains 500
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

The Telegram extension's media-group buffer flush window is hardcoded to 500ms and is only overridable via opts.testTimings.mediaGroupFlushMs, which is a test-only hook with no user-facing config path.

When network latency between Telegram's CDN and the gateway causes some album items to arrive >500ms after the first, the buffer flushes prematurely and the agent processes the message with partial media. Users see this as: "agent says it doesn't see the images, then if I wait, it processes them" — the agent reacts to the partial flush, then a second flush completes the rest.

This was originally reported as #1811 (closed as COMPLETED 2026-01-29) but the underlying constant is still hardcoded at 500ms in v2026.4.27, and the last comment on that thread reads "Still an issue for me!" — suggesting the closed-as-completed state didn't reflect a real fix, or a regression slipped in afterward.

Code reference (v2026.4.27)

dist/extensions/telegram/bot-Buo9I9xm.js:1159:

const mediaGroupTimeoutMs = typeof opts.testTimings?.mediaGroupFlushMs === "number"
  && Number.isFinite(opts.testTimings.mediaGroupFlushMs)
    ? Math.max(10, Math.floor(opts.testTimings.mediaGroupFlushMs))
    : 500;

The 500ms default is sensible, but there is no production-config path to raise it on slower networks.

Why messages.inbound.debounceMs doesn't cover this case

For completeness — inboundDebounceMs exists and is reachable via messages.inbound.debounceMs / messages.inbound.byChannel.telegram. But the default-lane shouldDebounce predicate in the same file (around line 1194) explicitly returns false for media-only messages without debounceable text:

if (!hasDebounceableText) return false;
return entry.allMedia.length === 0;

So pure-image albums (the most common multi-attachment case) bypass the inbound debouncer entirely and rely solely on the 500ms mediaGroupTimeoutMs. There is no current config knob that affects them.

Proposed solution

Expose mediaGroupTimeoutMs (or rename to mediaGroupFlushMs for parity with the test hook) as a user-facing key under the existing telegram channel config. Suggested location:

{
  "channels": {
    "telegram": {
      "mediaGroupFlushMs": 1500   // optional, default remains 500
    }
  }
}

Alternatively under messages.inbound.byChannel.telegram.mediaGroupFlushMs to colocate with the existing inbound-debounce settings.

Repro

  1. Send a Telegram album of 4+ images (no caption) to an OpenClaw-bound bot from a mobile client on a slower network.
  2. Observe the agent reply referencing fewer images than were sent, or "I don't see any images attached".
  3. Wait — a follow-up reply (or visible buffer flush in journalctl --user -u openclaw-gateway-<profile>.service) shows the remaining images arriving after the first flush.

Workarounds today

  • Adding a caption sometimes routes the message through paths that pick up the inbound debouncer (less reliable for media-only sends).
  • Forking the package to patch the constant.

Neither is reasonable for production users. The fix is small (~5 lines: read from cfg with the existing 500ms as fallback).

Environment

  • OpenClaw: 2026.4.27 (cbc2ba0)
  • Channel: Telegram (DM, default lane)
  • Symptom reproducible across multiple bots on the same gateway

cc #1811, related to #39343 (the Telegram half of that broader request would be resolved by this).

extent analysis

TL;DR

Exposing mediaGroupTimeoutMs as a user-facing configuration option under the Telegram channel config can help resolve the issue of premature buffer flushing due to network latency.

Guidance

  • The current hardcoded 500ms buffer flush window can be overridden by exposing mediaGroupTimeoutMs as a configurable option, allowing users to adjust the timeout based on their network conditions.
  • To verify the fix, send a Telegram album with multiple images (no caption) from a mobile client on a slower network and check if the agent reply references all the images sent.
  • Consider adding a configuration option under messages.inbound.byChannel.telegram.mediaGroupFlushMs to colocate with existing inbound-debounce settings.
  • Users can test the proposed solution by forking the package and patching the constant, but a user-facing config path is necessary for a production-ready fix.

Example

{
  "channels": {
    "telegram": {
      "mediaGroupFlushMs": 1500   // optional, default remains 500
    }
  }
}

Notes

The proposed solution requires a small code change (~5 lines) to read the configuration value with a fallback to the existing 500ms default.

Recommendation

Apply the proposed workaround by exposing mediaGroupTimeoutMs as a user-facing configuration option, as it provides a flexible solution for users with varying network conditions.

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 [Feature]: Telegram — expose mediaGroupTimeoutMs / mediaGroupFlushMs as a user-facing config key (follow-up to #1811) [1 comments, 2 participants]