feat(gateway): add @-mention-only filter for Mattermost channels#2279
Closed
vernonstinebaker wants to merge 1 commit into
Closed
feat(gateway): add @-mention-only filter for Mattermost channels#2279vernonstinebaker wants to merge 1 commit into
vernonstinebaker wants to merge 1 commit into
Conversation
The Mattermost adapter now only responds to messages in channels and groups when the bot is @-mentioned. DMs are always processed without filtering. Detection checks both the bot's @username and user ID in the message text, providing a reliable fallback when the structured mentions field is unavailable. Fixes NousResearch#2174
Contributor
|
Merged via PR #2443. Cherry-picked with authorship preserved. Thanks for the clean contribution! |
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.
What does this PR do?
Adds @-mention-only filtering to the Mattermost gateway adapter. The bot now only responds to messages in channels and groups when it is explicitly @-mentioned. DMs are always processed without filtering.
Currently, the Mattermost adapter processes every message from other users in channels, creating noise and unnecessary API calls. This brings Mattermost in line with Discord and Slack adapters which already filter for mentions.
Related Issue
Fixes #2174
Type of Change
Changes Made
gateway/platforms/mattermost.py: Added mention detection in_handle_post()after the existing "For channels, check for @mention" comment (line 580). Non-DM messages without a matching@usernameor@user_idin the message text are skipped with a debug log.How to Test
MATTERMOST_ALLOW_ALL_USERS=true@hermes-agent— it should respond normallyMattermost: skipping non-DM message without @mentiondebug entriesChecklist
Code
feat(gateway): ...)pytest tests/ -qand all tests passDocumentation & Housekeeping