Skip to content

fix(whatsapp): bypass text batching for slash commands - #46331

Closed
ardaaltinors wants to merge 1 commit into
NousResearch:mainfrom
ardaaltinors:fix/whatsapp-slash-bypass
Closed

fix(whatsapp): bypass text batching for slash commands#46331
ardaaltinors wants to merge 1 commit into
NousResearch:mainfrom
ardaaltinors:fix/whatsapp-slash-bypass

Conversation

@ardaaltinors

Copy link
Copy Markdown

Summary

WhatsApp text batching should collapse ordinary rapid-fire messages, but gateway slash commands need immediate handling. This keeps commands like /new, /reset, and /stop out of the debounce queue so control-plane actions are not delayed or merged with follow-up text.

Changes

  • Route polled WhatsApp events through a small dispatch helper.
  • Bypass text debounce for text events whose stripped content starts with /.
  • Keep ordinary text batching behavior unchanged.
  • Add focused tests for slash-command bypass and normal text enqueueing.

Validation

Check Result
Targeted tests 8 passed via python -m pytest tests/gateway/test_whatsapp_text_batching.py -q -o 'addopts='
Compile check python -m py_compile gateway/platforms/whatsapp.py passed
Whitespace git diff --check passed

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter duplicate This issue or pull request already exists labels Jun 14, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #36747 — same fix (bypass WhatsApp text-debounce batching for slash commands, regression of the #35391 batching change). Recommend consolidating on the earlier PR.

@ardaaltinors

ardaaltinors commented Jun 15, 2026

Copy link
Copy Markdown
Author

Thanks — agreed that this overlaps with #36747. I missed that PR when opening this one.

I re-checked because we hit the bug on a recent post-#35391 build, and that still makes sense: #36747 is open and has not landed on main yet. On current main I can reproduce the failure mode locally: normal text followed by /approve inside the WhatsApp debounce window gets flushed as one combined non-command payload (ok do it\n/approve).

I also tested #36747 in a separate worktree. It dispatches the slash command immediately and clears the pending normal-text batch, so it covers the actual failure mode better than this PR. This PR only has one tiny behavioral difference — it strips leading whitespace before checking / — but for the normal slash-command path #36747 is the right place to consolidate.

Happy to close this one and continue on #36747 to avoid duplicate review effort.

@ardaaltinors

Copy link
Copy Markdown
Author

Closing this as a duplicate of #36747. I re-checked both branches, and #36747 is the better place to land this fix because it also clears any pending normal-text batch before dispatching the slash command.

The only tiny thing from this PR that might still be useful is the leading-whitespace check for slash commands, so I left that note on #36747.

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 duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants