fix(gateway/telegram): skip messages that explicitly @mention another agent - #20464
Closed
Cullusion wants to merge 2 commits into
Closed
fix(gateway/telegram): skip messages that explicitly @mention another agent#20464Cullusion wants to merge 2 commits into
Cullusion wants to merge 2 commits into
Conversation
… agent In multi-agent group chats with require_mention disabled, all bots were responding to messages that @mentioned a different bot because _should_process_message() returned True immediately without checking whether an explicit mention was directed elsewhere. Adds _message_targets_other_bot() which scans Telegram MessageEntity objects for @mention and text_mention entities. If another account is explicitly mentioned but this bot is not, the method returns True and _should_process_message() returns False early — skipping the message regardless of the require_mention setting. Mirrors the cross-talk guard already present in the Discord adapter. Fixes NousResearch#20373 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…resolve_mention_targets _message_mentions_bot() and _message_targets_other_bot() previously each iterated over MessageEntity objects independently. Extract a shared _resolve_mention_targets() that performs a single pass and returns (self_mentioned, other_mentioned), then reduce both methods to thin wrappers around it. Also extends bot_command handling to set other_mentioned when a /cmd@other_bot disambiguation suffix does not match this bot, covering a case the previous implementation missed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Contributor
|
Automated hermes-sweeper review: this Telegram multi-bot mention routing fix is already implemented on current main. Evidence:
Thanks for the PR and for matching the Discord cross-talk guard direction; the same bug class is now handled on main. |
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
_message_targets_other_bot()to the Telegram adapter, which scansMessageEntityobjects for@mentionandtext_mentionentities directed at a different account_should_process_message()so that if another agent is explicitly @mentioned but this bot is not, the message is skipped early — regardless of therequire_mentionsetting_should_process_messagedocstring to document the new cross-talk guardRoot cause
_should_process_message()hitreturn Trueimmediately whenrequire_mention: false, before any check for whether the message was addressed to a different bot. In a multi-agent group this caused every bot to respond whenever any one of them was @mentioned.Test plan
require_mention: false— bot still responds to all messages with no @mention@other_bot do this— onlyother_botresponds, not this bot@this_bot do this— this bot responds normally@this_bot @other_bot help— both bots respond (both mentioned)Fixes #20373
🤖 Generated with Claude Code