fix(matrix): trust m.mentions.user_ids as authoritative mention signal#8673
Closed
teknium1 wants to merge 1 commit into
Closed
fix(matrix): trust m.mentions.user_ids as authoritative mention signal#8673teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Non- OpenClaw Matrix clients (Element, matrix-bot-sdk bots, etc.) commonly send messages with proper m.mentions.user_ids metadata but without duplicating the @bot text in the message body. Before this change, _is_bot_mentioned() relied entirely on text-based detection (body string matching and HTML pill detection), causing messages from these clients to be silently dropped when MATRIX_REQUIRE_MENTION=true. Now, if the bot's user_id appears in m.mentions.user_ids, that alone is sufficient to register a mention — matching the Matrix spec. Text-based fallback remains for backwards compatibility with older clients that don't populate m.mentions.
teknium1
added a commit
that referenced
this pull request
Apr 13, 2026
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Clients that populate m.mentions but don't duplicate @bot in the body text were being silently dropped when MATRIX_REQUIRE_MENTION=true. Cherry-picked from PR #8673.
teknium1
added a commit
that referenced
this pull request
Apr 13, 2026
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Clients that populate m.mentions but don't duplicate @bot in the body text were being silently dropped when MATRIX_REQUIRE_MENTION=true. Cherry-picked from PR #8673.
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Clients that populate m.mentions but don't duplicate @bot in the body text were being silently dropped when MATRIX_REQUIRE_MENTION=true. Cherry-picked from PR NousResearch#8673.
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Clients that populate m.mentions but don't duplicate @bot in the body text were being silently dropped when MATRIX_REQUIRE_MENTION=true. Cherry-picked from PR NousResearch#8673.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Clients that populate m.mentions but don't duplicate @bot in the body text were being silently dropped when MATRIX_REQUIRE_MENTION=true. Cherry-picked from PR NousResearch#8673.
olympus-terminal
pushed a commit
to olympus-terminal/hermes-agent
that referenced
this pull request
May 16, 2026
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Clients that populate m.mentions but don't duplicate @bot in the body text were being silently dropped when MATRIX_REQUIRE_MENTION=true. Cherry-picked from PR NousResearch#8673.
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
Port from openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7, the m.mentions.user_ids field is the authoritative mention signal. Clients that populate m.mentions but don't duplicate @bot in the body text were being silently dropped when MATRIX_REQUIRE_MENTION=true. Cherry-picked from PR NousResearch#8673.
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
Port of openclaw/openclaw#64796: Per MSC3952 / Matrix v1.7,
m.mentions.user_idsis the authoritative mention signal in the Matrix spec.Problem
Non-Hermes Matrix clients (Element, matrix-bot-sdk bots, etc.) commonly send messages with proper
m.mentions.user_idsmetadata but without duplicating the@bottext in the message body. For example:{ "body": "please reply", "m.mentions": { "user_ids": ["@hermes:matrix.org"] } }Before this change,
_is_bot_mentioned()relied entirely on text-based detection (body string matching + HTML pill detection). These messages were silently dropped whenMATRIX_REQUIRE_MENTION=true— effectively breaking mention-gating for any Matrix room receiving messages from non-Hermes clients.Solution
mention_user_idsparameter to_is_bot_mentioned()m.mentions.user_ids, that alone is sufficient to register a mentionm.mentions.user_idsfrom event content in_resolve_message_context()and pass it throughArchitectural Differences from OpenClaw
OpenClaw's fix removed the body-text requirement from a conjunction. Our implementation adds
m.mentions.user_idsas a new first-check in the detection chain, preserving the existing text-based checks unchanged as fallback.Tests
_is_bot_mentioned()withmention_user_ids_on_room_message()verifying the full flowTest plan
python3 -m pytest tests/gateway/test_matrix_mention.py -o 'addopts=' -q