Quick Start
1
Enable album coalescing
Set
media_group_window_ms on BotConfig.metadata to switch coalescing on. 0 (the default) keeps every album part as its own turn.2
Tune the album size cap
Add
media_group_max to bound how many attachments buffer per album before a forced flush. The default (10) covers a full Telegram album.How It Works
Telegram delivers each album part as its own update sharing onemedia_group_id. The coalescer buffers the parts and flushes them once, after a short window of silence.
Exactly one caller per group receives the MergedAlbum; sibling handle_message calls return None because their media was folded into the owner’s turn. A standalone (non-album) message has no media_group_id, so it returns its own parts immediately — no debounce added.
Configuration Options
Both knobs live onBotConfig.metadata (passthrough — there are no dedicated BotConfig fields).
The feature is disabled by default (
media_group_window_ms=0). Existing deployments are unchanged until you set the knob.Common Patterns
Compare several images in one turn:Best Practices
Start with 1200 ms
Start with 1200 ms
1200 ms covers Telegram’s typical inter-part gap. Raise it only if slow phones trickle parts across more than a second.Keep media_group_max at the default
Keep media_group_max at the default
The default (
10) fits a full Telegram album. Lower it only when you have a specific latency or memory target — doing so splits a single album across multiple turns.The feature is opt-in
The feature is opt-in
Clean deployments stay byte-for-byte unchanged until you set
media_group_window_ms. Enabling it never affects existing behaviour for other message types.Standalone media is unaffected
Standalone media is unaffected
Single-photo messages have no
media_group_id, so they return immediately with no added debounce — album coalescing only touches multi-part albums.Related
Messaging Bots
Inbound photos and documents handed to the agent’s vision capability.
Telegram Durable Approval
Another Telegram-specific gateway feature — durable Allow/Deny buttons.

