feat(mattermost): follow thread after @mention (Slack parity) - #54193
feat(mattermost): follow thread after @mention (Slack parity)#54193wernerhp wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Slack-parity “engaged thread” behavior to the Mattermost gateway adapter: after the bot is first @mentioned in a thread, it will respond to subsequent messages in that thread without requiring another mention (with an opt-out strict mode).
Changes:
- Track “mentioned threads” in the Mattermost adapter and bypass the mention gate for follow-ups in those threads (unless strict mention mode is enabled).
- Add Mattermost gateway tests covering in-thread auto-response and strict-mention behavior.
- Update Mattermost docs + environment variable reference to document
MATTERMOST_STRICT_MENTIONand the in-thread behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
plugins/platforms/mattermost/adapter.py |
Implements bounded per-thread engagement tracking and strict-mention toggle. |
tests/gateway/test_mattermost.py |
Adds test cases for in-thread auto-response + strict mention behavior. |
website/docs/user-guide/messaging/mattermost.md |
Documents new in-thread conversation behavior and strict mention opt-out. |
website/docs/reference/environment-variables.md |
Documents MATTERMOST_STRICT_MENTION (and also includes additional unrelated env-var doc edits). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary\n\nVerdict: LGTM\n\nMattermost in-thread auto-response: after an @mention, follow-ups in the same thread bypass the mention gate. Bounded by _MENTIONED_THREADS_MAX (5000). Configurable via MATTERMOST_STRICT_MENTION env var or config.extra.strict_mention. Clean implementation mirroring Slack adapter behavior.\n\n---\nReviewed by Hermes Agent
ddbe6e3 to
7ee6a63
Compare
a2ebff8 to
9872d21
Compare
tonydwb
left a comment
There was a problem hiding this comment.
Well-designed Mattermost feature (115 additions). After an @mention, follow-ups in the same thread skip the mention gate. Bounded by _MENTIONED_THREADS_MAX (5000). MATTERMOST_STRICT_MENTION env var for opt-out. Good test coverage and documentation.
Reviewed by Hermes Agent
9872d21 to
2ef9363
Compare
2ef9363 to
b9419b3
Compare
b53a2ef to
79548f9
Compare
e43b51a to
3f634be
Compare
3ecbdd4 to
125171b
Compare
125171b to
1ae4ba9
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused Mattermost parity work. The reported default behavior remains present on current main: plugins/platforms/mattermost/adapter.py:849-854 returns before an unmentioned thread reply reaches the event handler.
Problems
- The restart fallback builds its source with
user_id=Noneatplugins/platforms/mattermost/adapter.py:1070, while the real inbound path usessender_idatplugins/platforms/mattermost/adapter.py:934-940. Withthread_sessions_per_user=True,gateway/session.py:949-957appends that user ID, so the fallback cannot find the stored session. - The same fallback omits the profile namespace (
plugins/platforms/mattermost/adapter.py:1086-1090). In multiplex mode, the runner stampssource.profilebefore dispatch (gateway/run.py:8629-8638) andSessionStoreuses it in generated keys (gateway/session.py:1358-1365), so secondary-profile recovery also misses.
Suggested changes
- Derive the recovery key from the full inbound session identity, including user and profile, or defer the persistent fallback while retaining the in-process mentioned-thread behavior.
- Add regressions for per-user thread sessions and multiplexed-profile sessions; the current key test only covers the shared/default path.
Automated hermes-sweeper review.
…ssion lookup teknium1 review on PR NousResearch#54193: _has_active_session_for_thread recomputed the session key with user_id=None and no profile namespace, so post-restart thread-continuation lookups always missed sessions created with thread_sessions_per_user=True or under a secondary adapter profile. - Thread the inbound post's sender_id through to the lookup so the key matches session creation when thread_sessions_per_user=True. - Resolve the profile namespace via SessionStore._resolve_profile_for_key so secondary-profile sessions (agent:<profile>) are found instead of silently searching agent:main. - Add regression tests pinning both behaviors (revert-to-fail verified).
278fd9d to
24dfd03
Compare
7c520c4 to
39be51c
Compare
After the bot is @mentioned in a non-DM Mattermost channel, follow-up messages in that thread are answered without re-mentioning, matching the existing Slack behaviour. Opt out with `strict_mention: true` in the mattermost config block (bridged to MATTERMOST_STRICT_MENTION internally). Fixes the session-key chat_type mismatch that would silently no-op the session-presence check in public channels.
…ssion lookup teknium1 review on PR NousResearch#54193: _has_active_session_for_thread recomputed the session key with user_id=None and no profile namespace, so post-restart thread-continuation lookups always missed sessions created with thread_sessions_per_user=True or under a secondary adapter profile. - Thread the inbound post's sender_id through to the lookup so the key matches session creation when thread_sessions_per_user=True. - Resolve the profile namespace via SessionStore._resolve_profile_for_key so secondary-profile sessions (agent:<profile>) are found instead of silently searching agent:main. - Add regression tests pinning both behaviors (revert-to-fail verified).
885e4a7 to
bb34d76
Compare
What does this PR do?
After the bot is
@mentionedin a Mattermost channel thread, follow-upmessages in that thread are answered without requiring another
@mention,matching Slack adapter behaviour.
_mentioned_threads(bounded to_MENTIONED_THREADS_MAX = 5000)MATTERMOST_STRICT_MENTIONenv var ormattermost.strict_mention: trueinconfig.yaml_has_active_session_for_thread(): secondary auto-follow signal — responds in threads with an existing session even after a restart (mirrorsSlackAdapter._has_active_session_for_thread)_apply_yaml_configbridge forMATTERMOST_STRICT_MENTION(consistent withrequire_mentionpattern)Related Issues
Closes #54188
Type of Change
strict_mention)Changes Made
plugins/platforms/mattermost/adapter.py:_mentioned_threads,_mm_strict_mention(),_has_active_session_for_thread(), gate ladder,_apply_yaml_configbridgetests/gateway/test_mattermost.py: in-thread auto-response, strict-mention, session-continuity coveragewebsite/docs/reference/environment-variables.md:MATTERMOST_STRICT_MENTIONrowwebsite/docs/user-guide/messaging/mattermost.md: configuration guidance