fix(whatsapp): enforce require_mention in group chats - #4730
Merged
Conversation
…ctive message unwrapping Address feature gaps vs Telegram/Discord/Mattermost adapters: - free_response_chats whitelist to bypass mention gating per-group - strip bot @phone mentions from body before forwarding to agent - unwrap templateMessage/buttonsMessage/listMessage in bridge - info-level log on successful mention pattern compilation - use module-level json import instead of inline import in config - eliminate double _normalize_whatsapp_id call via walrus operator - hoist botIds computation outside per-message loop in bridge
This was referenced Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings WhatsApp group chat handling to parity with Telegram's mention gating system. Previously, every message in a WhatsApp group hit the agent. Now the bot only responds when directly triggered.
Cherry-picked from PR #4694 by @kshitijk4poor. Also supersedes #3636.
Changes
gateway/platforms/whatsapp.py): Addrequire_mention/mention_patterns/free_response_chatsconfig support, mirroring Telegram's established patterngateway/config.py): Bridgewhatsapp.require_mention,whatsapp.mention_patterns, andwhatsapp.free_response_chatsfrom config.yaml to env varsscripts/whatsapp-bridge/bridge.js): ForwardmentionedIds,quotedParticipant,botIdsto adapter; refactor message body extraction to properly handle ephemeral/viewOnce/template messagestests/gateway/test_whatsapp_group_gating.py): 10 test cases covering all gating scenariosConfig
Group message acceptance cascade
DMs always pass. Group messages are accepted when:
free_response_chatsrequire_mentionis disabled (default)/commandmention_patternsregexBackward compatible — defaults to
require_mention: false.Test results