Skip to content

fix(whatsapp): lower default debounce delays to match Telegram cadence - #44896

Open
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/whatsapp-text-batch-defaults
Open

fix(whatsapp): lower default debounce delays to match Telegram cadence#44896
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/whatsapp-text-batch-defaults

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Lowers the WhatsApp adapter's default text-batch debounce delays from 5.0s/10.0s to 0.3s/2.0s, matching the Telegram adapter's TTFT-optimised cadence. A single "hello" message previously waited 5 seconds of dead silence before the agent responded.

Related Issue

Fixes #44883

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/platforms/whatsapp.py: Changed text_batch_delay_seconds default from 5.0 to 0.3, text_batch_split_delay_seconds from 10.0 to 2.0. Updated docstring comment.
  • tests/gateway/test_whatsapp_text_batching.py: Updated 3 test assertions to match new defaults (default test, invalid-config fallback test, env-var-ignored test).

How to Test

  1. Send any single text message on WhatsApp with default config
  2. Observe the agent responds within ~0.3s instead of waiting 5s
  3. Verify text_batch_delay_seconds override still works: set gateway.platforms.whatsapp.extra.text_batch_delay_seconds: 1.0 in config.yaml and confirm the delay changes
  4. Run pytest tests/gateway/test_whatsapp_text_batching.py -q — all 6 tests pass

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/gateway/test_whatsapp_text_batching.py -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

Code Intelligence

⚠️ GitNexus unavailable — grep-based fallback used.

  • Checked files: gateway/platforms/whatsapp.py (debounce init), tests/gateway/test_whatsapp_text_batching.py (6 tests)
  • Callers of _coerce_float_extra for batch delays: WhatsAppAdapter.init only
  • Blast radius: LOW — default value change only, no control flow changes. Override path via config.extra unchanged.
  • Related patterns: Telegram adapter uses 0.3s/1.0s with _env_float_clamped (PR perf(gateway): tune Telegram cadence + adaptive fast-path for short replies (salvage of #10388) #23587). Matrix adapter also uses text_batch_delay_seconds with similar config.extra pattern.

PR NousResearch#35391 introduced text-debounce batching for WhatsApp with defaults
of 5.0s / 10.0s — 16× slower than Telegram's 0.3s / 1.0s.  A single
"hello" message waits 5 seconds of dead silence before the agent
responds, and most users will never discover the config knob.

Lower the defaults to 0.3s / 2.0s, matching the Telegram adapter's
TTFT-optimised cadence.  Operators can still override via
config.yaml (gateway.platforms.whatsapp.extra.text_batch_delay_seconds).

Fixes NousResearch#44883

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Clean config fix. WhatsApp text batching delays reduced from 5.0s/10.0s to 0.3s/2.0s to match the Telegram adapter cadence.

Looks Good

  • Lower delays mean faster response for WhatsApp users without flooding
  • Existing tests updated to match new defaults
  • Config fallback logic unchanged — garbage/invalid values still fall back to new defaults
  • Clear documentation noting this matches Telegram adapter behavior

Reviewed by Hermes Agent

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused latency fix. The premise still holds on current main: plugins/platforms/whatsapp/adapter.py:436-441 retains the 5.0s/10.0s defaults, which _flush_text_batch() awaits before dispatch at plugins/platforms/whatsapp/adapter.py:1315-1325.

Problems

  • The PR modifies the retired gateway/platforms/whatsapp.py; the live adapter moved to plugins/platforms/whatsapp/adapter.py in 560010547 (2026-06-19), so this diff would not alter current runtime behavior.
  • website/docs/user-guide/messaging/whatsapp.md:214-223 would continue to document 5s/10s after the code change.

Suggested changes

  • Salvage the default and test assertions onto the plugin adapter/current test import, and update the WhatsApp configuration example.
  • Clarify the 2.0s split choice: Telegram currently uses 1.0s at plugins/platforms/telegram/adapter.py:572-576.

This is an automated hermes-sweeper review.

adapter = _make_adapter()
assert adapter._text_batch_delay_seconds == 5.0
assert adapter._text_batch_split_delay_seconds == 10.0
assert adapter._text_batch_delay_seconds == 0.3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main's test already imports plugins.platforms.whatsapp.adapter, but the production half of this PR still edits the retired gateway/platforms/whatsapp.py. Port the matching defaults to plugins/platforms/whatsapp/adapter.py; otherwise this updated assertion will not match runtime behavior.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
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 sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhatsApp gateway: 5s default debounce introduced in PR#35391 adds 5s latency to every response

4 participants