diff --git a/gateway/platforms/whatsapp.py b/gateway/platforms/whatsapp.py index d833d5649a221..98c09791d97a1 100644 --- a/gateway/platforms/whatsapp.py +++ b/gateway/platforms/whatsapp.py @@ -296,16 +296,16 @@ def __init__(self, config: PlatformConfig): # WhatsApp often delivers multiple messages in rapid succession # (e.g. forwarded batches, paste-splits) — without debounce each # message triggers a separate agent invocation, wasting tokens and - # flooding the user with reply fragments. Default 5s delay / - # 10s split delay are conservative for WhatsApp's delivery cadence. + # flooding the user with reply fragments. Default 0.3s delay / + # 2.0s split delay match the Telegram adapter's cadence. # Tunable via config.yaml under # ``gateway.platforms.whatsapp.extra.text_batch_delay_seconds`` / # ``text_batch_split_delay_seconds``. self._text_batch_delay_seconds = self._coerce_float_extra( - "text_batch_delay_seconds", 5.0 + "text_batch_delay_seconds", 0.3 ) self._text_batch_split_delay_seconds = self._coerce_float_extra( - "text_batch_split_delay_seconds", 10.0 + "text_batch_split_delay_seconds", 2.0 ) self._pending_text_batches: Dict[str, MessageEvent] = {} self._pending_text_batch_tasks: Dict[str, asyncio.Task] = {} diff --git a/tests/gateway/test_whatsapp_text_batching.py b/tests/gateway/test_whatsapp_text_batching.py index 4258617c6784f..a5de6cce3187f 100644 --- a/tests/gateway/test_whatsapp_text_batching.py +++ b/tests/gateway/test_whatsapp_text_batching.py @@ -35,8 +35,8 @@ def _event(text): def test_batch_delays_default_from_config(): 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 + assert adapter._text_batch_split_delay_seconds == 2.0 def test_batch_delays_overridden_via_config_extra(): @@ -53,15 +53,15 @@ def test_invalid_config_value_falls_back_to_default(): text_batch_delay_seconds="garbage", text_batch_split_delay_seconds=-3, ) - 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 + assert adapter._text_batch_split_delay_seconds == 2.0 def test_env_var_is_ignored(monkeypatch): # Config-only path: the legacy HERMES_* env var must NOT influence delays. monkeypatch.setenv("HERMES_WHATSAPP_TEXT_BATCH_DELAY_SECONDS", "99") adapter = _make_adapter() - assert adapter._text_batch_delay_seconds == 5.0 + assert adapter._text_batch_delay_seconds == 0.3 def test_rapid_texts_collapse_into_single_dispatch():