Skip to content

feat(gateway): WhatsApp inbound plain-text batching (Telegram-style) - #17165

Closed
keiravoss94 wants to merge 3 commits into
NousResearch:mainfrom
pebble-tech:feature/whatsapp-inbound-text-batch
Closed

feat(gateway): WhatsApp inbound plain-text batching (Telegram-style)#17165
keiravoss94 wants to merge 3 commits into
NousResearch:mainfrom
pebble-tech:feature/whatsapp-inbound-text-batch

Conversation

@keiravoss94

@keiravoss94 keiravoss94 commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds adapter-level text batching for the WhatsApp gateway adapter so multiple plain-text bubbles (or rapid follow-ups) merge into one agent turn after a quiet period, matching the debounce behavior already used on Telegram, Discord, and Matrix.

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/whatsapp.py — debounced text batching with HERMES_WHATSAPP_TEXT_BATCH_DELAY_SECONDS (default 0.6)
  • tests/gateway/test_text_batching.py — batching behavior tests
  • tests/gateway/test_whatsapp_connect.py — disconnect cleanup for batch timers
  • website/docs/reference/environment-variables.md — document batch delay env var
  • website/docs/user-guide/messaging/whatsapp.md — document batching behavior

How to Test

  1. uv run pytest -o addopts= tests/gateway/test_text_batching.py tests/gateway/test_whatsapp_connect.py -q
  2. Send several rapid plain-text WhatsApp messages to the gateway — confirm they arrive as a single merged turn after the quiet period
  3. Send a message with media or a long chunk — confirm it flushes immediately without waiting for unrelated batch slots

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

N/A — delete this section otherwise.

Screenshots / Logs

N/A

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter labels Apr 28, 2026
github-actions Bot pushed a commit to pebble-tech/hermes-agent that referenced this pull request Apr 30, 2026
…TURE_BRANCHES

Cherry-picks after busy-path stack tip; update FORK.md upstream PR table.
@keiravoss94
keiravoss94 force-pushed the feature/whatsapp-inbound-text-batch branch from 5d15931 to 889ff6a Compare May 1, 2026 07:25
@github-actions
github-actions Bot force-pushed the feature/whatsapp-inbound-text-batch branch from 889ff6a to c41808b Compare May 1, 2026 14:19
@github-actions
github-actions Bot force-pushed the feature/whatsapp-inbound-text-batch branch from c41808b to 7f4938b Compare May 2, 2026 05:41
@github-actions
github-actions Bot force-pushed the feature/whatsapp-inbound-text-batch branch from 7f4938b to 3c6ef34 Compare May 3, 2026 06:08
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from 3c6ef34 to 644578e Compare May 3, 2026 15:00
@github-actions
github-actions Bot force-pushed the feature/whatsapp-inbound-text-batch branch from 644578e to a7ad276 Compare May 4, 2026 06:17
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from a7ad276 to 8fedd1d Compare May 6, 2026 07:02
@github-actions
github-actions Bot force-pushed the feature/whatsapp-inbound-text-batch branch from 79c164d to 91b235d Compare May 13, 2026 07:45
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from 91b235d to 3745bf5 Compare May 13, 2026 07:51
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from 3745bf5 to 3f68ca0 Compare May 13, 2026 16:33
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from 3f68ca0 to 344c3e2 Compare May 13, 2026 17:12
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from 344c3e2 to b35ca60 Compare May 13, 2026 18:34
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from b35ca60 to 0934407 Compare May 24, 2026 08:35
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from 84ba5d4 to 1638e04 Compare May 25, 2026 07:18
@vKongv
vKongv force-pushed the feature/whatsapp-inbound-text-batch branch from 1638e04 to c6b486d Compare May 26, 2026 06:50
keiravoss94 and others added 3 commits May 30, 2026 06:26
Merge rapid text bubbles after a configurable quiet period (env:
HERMES_WHATSAPP_TEXT_BATCH_*). Adaptive delay near split threshold.
Docs + tests for adapter-level batching.
- enqueue photo bursts like Telegram; flush after HERMES_WHATSAPP_MEDIA_BATCH_DELAY_SECONDS (default 0.8)
- cancel photo batch tasks on disconnect alongside text batches
- docs and tests
_make_adapter bypasses __init__ but disconnect cancels text/photo batch
timers; stub the dicts the production path expects. Pin ACP model-switch
test via _resolve_model_selection to avoid provider-registry flakes.
@teknium1

Copy link
Copy Markdown
Contributor

Superseded by PR #35391 (merged, commit cddb728), which adds text-debounce batching to both WhatsApp and Weixin. The implementation was salvaged from @redpiggy-cyber's PR #35302 (both adapters) and adapted to the config.yaml path. Thanks for the earlier WhatsApp-only proposal here — closing as covered by the merged change.

#35391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants