← Back to PRs

#15467: feat(messages): add debounceMedia option for inbound debouncing

by tangcruz open 2026-02-13 13:47 View on GitHub →
docs channel: discord channel: telegram channel: whatsapp-web stale size: S
## 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