360 Secure SkillHub
360 安全技能中心

Matrix Mentions Patch

针对OpenClaw Matrix插件在配置requireMention: true后仍不响应群聊@提及的问题,提供修复方案。根因是调用buildMentionRegexes函数时未传agentId,导致无法生成正确的提及检测规则。核心功能是给出具体代码修改步骤及重启OpenClaw网关的操作,无需重建即可生效,适用于遇到该提及失效bug的场景。

biociao
biociao
热度 54.23
最近更新 2026-05-16 11:16:46
分类:开发依赖:纯提示词应用场景:调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add matrix-mentions-patch
Metadata
name
matrix-mentions-patch
description
Fix OpenClaw Matrix plugin mention detection bug. Use when OpenClaw doesn't respond to @mentions in Matrix group rooms despite correct configuration. The bug is that buildMentionRegexes() is called without agentId, causing mention patterns to not be built correctly.

Matrix Mentions Patch

Problem

OpenClaw Matrix plugin doesn't respond to @mentions in group rooms even when:

  • The room is configured with requireMention: true
  • The user correctly @mentions the bot (e.g., @runwheezy:matrix.biochao.cc)

Root Cause

In /home/bot/.openclaw/extensions/matrix/src/matrix/monitor/index.ts, the buildMentionRegexes function is called WITHOUT passing agentId:

// BUG: Missing agentId parameter
const mentionRegexes = core.channel.mentions.buildMentionRegexes(cfg);

Without agentId, the function can't resolve agent-specific mention patterns from config, causing mentions to never be detected.

Fix

Edit /home/bot/.openclaw/extensions/matrix/src/matrix/monitor/index.ts:

Find line ~298:

const mentionRegexes = core.channel.mentions.buildMentionRegexes(cfg);

Change to:

const mentionRegexes = core.channel.mentions.buildMentionRegexes(cfg, "main");

Replace "main" with your actual agent ID if different.

Apply

  1. Make the edit above
  2. Restart OpenClaw gateway: openclaw gateway restart

The fix loads immediately - no rebuild needed since the extension is loaded dynamically.