-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
[Bug]: bug(matrix): 2-person rooms incorrectly classified as DMs, causing message routing confusion #30645
Description
Summary
Problem
When a user has two separate 2-person Matrix rooms involving the same participants (e.g., a dedicated bot room and a topic-specific room), OpenClaw incorrectly treats both rooms as DMs based solely on member count. This causes replies to be routed to both rooms simultaneously, producing duplicate or out-of-context messages.
Root Cause
createDirectRoomTracker falls back to memberCount === 2 as a DM heuristic:
const memberCount = await resolveMemberCount(roomId);
if (memberCount === 2) {
return true; // treats any 2-person room as a DM
}This conflicts with the Matrix spec, which designates DMs via explicit m.direct account data and member state is_direct: true — not by member count.
Steps to reproduce
- Create two Matrix rooms each with exactly 2 members (bot + same user)
- Mark only one as a DM in your Matrix client
- Send a message in the non-DM room → OpenClaw routes as if it were a DM
Expected behavior
A 2-person room should only be treated as a DM if it is explicitly marked as one (via m.direct or is_direct member state). Otherwise it should be handled as a regular group room.
Actual behavior
This causes replies to be routed to both rooms simultaneously, producing duplicate or out-of-context messages.
OpenClaw version
2026.2.17
Operating system
macOS 15.4
Install method
No response
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response