#15467: feat(messages): add debounceMedia option for inbound debouncing
docs
channel: discord
channel: telegram
channel: whatsapp-web
stale
size: S
Cluster:
Messaging Platform Improvements
## Summary
- Add `messages.inbound.debounceMedia` config option (boolean, default `false`)
- When enabled, media/attachment messages are debounced like text instead of flushing immediately
- Debounced media from the same sender is combined into a single agent turn with all attachments
## Problem
In group chats, users often send multiple screenshots in quick succession (e.g., customer service calibration, multi-image bug reports). Currently each image bypasses inbound debouncing and triggers a separate agent run, causing the bot to respond N times instead of once. This wastes tokens and creates a poor user experience.
## Changes
| File | Change |
|------|--------|
| `src/config/types.messages.ts` | Add `debounceMedia?: boolean` to `InboundDebounceConfig` |
| `src/config/zod-schema.core.ts` | Add schema validation for the new field |
| `src/auto-reply/inbound-debounce.ts` | Add `resolveDebounceMedia()` helper |
| `src/telegram/bot-handlers.ts` | Respect config; combine media in `onFlush` |
| `src/discord/monitor/message-handler.ts` | Respect config for attachments |
| `src/web/auto-reply/monitor.ts` | Respect config for WhatsApp media |
| `src/auto-reply/inbound.test.ts` | Unit tests for `resolveDebounceMedia` |
| `docs/concepts/messages.md` | Document new option |
## Usage
```json5
{
messages: {
inbound: {
debounceMs: 5000,
debounceMedia: true,
},
},
}
```
## Backward compatibility
Default is `false` — existing behavior is completely unchanged. Opt-in only.
## Test plan
- [x] `pnpm tsc --noEmit` passes
- [x] `resolveDebounceMedia` unit tests pass (3 cases: unset, false, true)
- [x] All existing inbound debounce tests still pass
- [x] Linter + formatter pass
- [ ] Manual: send multiple images in Telegram group with `debounceMedia: true`, verify single batched response
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds a new `messages.inbound.debounceMedia` boolean config (default `false`) and threads it through inbound debouncing for Telegram, Discord, and WhatsApp Web so that media/attachment messages can be batched instead of flushing immediately. It also adds schema/type support and documents the new option.
Main concern: the Discord implementation currently drops attachments when combining debounced messages. `shouldDebounce` will allow attachment messages when `debounceMedia` is enabled, but `onFlush` constructs a synthetic message with `attachments: []`, and downstream media extraction relies on `message.attachments`. This means batched Discord media turns will lose all attachments instead of combining them.
<h3>Confidence Score: 3/5</h3>
- Mergeable after fixing a functional bug in Discord attachment batching.
- Most changes are straightforward config plumbing and behavior gating. However, the Discord debounced-flush path currently clears `message.attachments`, so enabling `debounceMedia` would silently drop attachments in batched turns; this is a user-visible functional regression for the new feature.
- src/discord/monitor/message-handler.ts
<sub>Last reviewed commit: d87823f</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#14057: feat(telegram): add ignoreMediaTypes config to skip specific inboun...
by pavelsamoylenko · 2026-02-11
81.7%
#20594: feat(whatsapp): batch multi-image messages via debouncer
by arniesaha · 2026-02-19
81.4%
#17435: fix(debounce): retry flush with exponential backoff to prevent sile...
by widingmarcus-cyber · 2026-02-15
80.2%
#22434: feat(telegram): support sending original quality images
by godenjan · 2026-02-21
78.0%
#10509: fix(telegram): bare abort words bypass debounce + clear buffered me...
by romancircus · 2026-02-06
77.1%
#20913: fix: intercept Discord embed images to enforce mediaMaxMb
by MumuTW · 2026-02-19
77.0%
#15853: feat: add option to suppress media placeholder text
by MisterGuy420 · 2026-02-14
76.8%
#21309: feat(telegram): support outbound media groups (albums) via sendMedi...
by smysle · 2026-02-19
76.8%
#8368: fix(telegram): preserve forwarded message metadata during debounce ...
by PatrickBauer · 2026-02-03
76.6%
#15985: fix(telegram): defer buffer deletion until processing succeeds
by coygeek · 2026-02-14
76.4%