Summary
When requireMention: true is set for a Matrix group room, messages containing valid m.mentions metadata are not detected as mentions, causing all agents to ignore the message. This effectively makes requireMention: true unusable for rooms where messages may come from non-OpenClaw Matrix clients or bots.
Environment
- OpenClaw: 2026.4.9
- Matrix homeserver: Synapse (Docker, localhost)
- Node: 25.9.0
Steps to Reproduce
- Configure a Matrix group room with
requireMention: true:
"groups": {
"!roomId:localhost": {
"requireMention": true,
"enabled": true
}
}
- From a non-OpenClaw Matrix client (e.g., Element, or a standalone bot using matrix-bot-sdk), send a message to the room with proper
m.mentions:
{
"msgtype": "m.text",
"body": "@欢欢 please reply",
"format": "org.matrix.custom.html",
"formatted_body": "<a href=\"https://matrix.to/#/@huanhuan:localhost\">@欢欢</a> please reply",
"m.mentions": {
"user_ids": ["@huanhuan:localhost"]
}
}
-
Observe: no agent responds. The mentioned agent (@huanhuan:localhost) does not get triggered.
-
Set requireMention: false → the same message triggers all agents (including unmentioned ones).
Expected Behavior
With requireMention: true, the agent whose userId appears in m.mentions.user_ids AND whose name/userId appears in the formatted_body matrix.to link should be triggered. Other agents should remain silent.
Actual Behavior
No agent is triggered. The message is silently dropped for all agents.
Analysis
Looking at extensions/matrix/src/matrix/monitor/mentions.ts, resolveMentions() checks:
m.mentions.user_ids contains the agent's userId AND formatted_body or text contains a matching pattern (line 166-170)
formatted_body has a matrix.to link for the agent (line 158-165)
- Text matches
mentionRegexes (line 150-153)
The message I sent satisfies conditions 1 and 2. Possible causes:
- The sender (
@eventbridge:localhost) is in groupAllowFrom but is not an OpenClaw-managed account — perhaps inbound message processing skips mention resolution for certain senders
- The
mentionRegexes auto-generated from identity.name may not match CJK display names correctly
- There may be an earlier filter that drops the message before
resolveMentions() is called
Impact
requireMention: true is the only way to prevent agents from responding to every message in a group chat. Without it, multi-agent rooms suffer from:
- Agents responding to messages not directed at them ("插嘴" / interrupting)
- Unnecessary API calls and token consumption
- Potential cascading loops when error messages trigger all agents
Currently the only workaround is requireMention: false + adding "only respond to messages addressed to you" in each agent's SOUL.md, which is unreliable (LLM-based filtering).
Related
🤖 Generated with Claude Code
Summary
When
requireMention: trueis set for a Matrix group room, messages containing validm.mentionsmetadata are not detected as mentions, causing all agents to ignore the message. This effectively makesrequireMention: trueunusable for rooms where messages may come from non-OpenClaw Matrix clients or bots.Environment
Steps to Reproduce
requireMention: true:m.mentions:{ "msgtype": "m.text", "body": "@欢欢 please reply", "format": "org.matrix.custom.html", "formatted_body": "<a href=\"https://matrix.to/#/@huanhuan:localhost\">@欢欢</a> please reply", "m.mentions": { "user_ids": ["@huanhuan:localhost"] } }Observe: no agent responds. The mentioned agent (
@huanhuan:localhost) does not get triggered.Set
requireMention: false→ the same message triggers all agents (including unmentioned ones).Expected Behavior
With
requireMention: true, the agent whose userId appears inm.mentions.user_idsAND whose name/userId appears in theformatted_bodymatrix.to link should be triggered. Other agents should remain silent.Actual Behavior
No agent is triggered. The message is silently dropped for all agents.
Analysis
Looking at
extensions/matrix/src/matrix/monitor/mentions.ts,resolveMentions()checks:m.mentions.user_idscontains the agent's userId ANDformatted_bodyor text contains a matching pattern (line 166-170)formatted_bodyhas amatrix.tolink for the agent (line 158-165)mentionRegexes(line 150-153)The message I sent satisfies conditions 1 and 2. Possible causes:
@eventbridge:localhost) is ingroupAllowFrombut is not an OpenClaw-managed account — perhaps inbound message processing skips mention resolution for certain sendersmentionRegexesauto-generated fromidentity.namemay not match CJK display names correctlyresolveMentions()is calledImpact
requireMention: trueis the only way to prevent agents from responding to every message in a group chat. Without it, multi-agent rooms suffer from:Currently the only workaround is
requireMention: false+ adding "only respond to messages addressed to you" in each agent's SOUL.md, which is unreliable (LLM-based filtering).Related
requireMention: false🤖 Generated with Claude Code