Skip to content

[Bug]: bug(matrix): 2-person rooms incorrectly classified as DMs, causing message routing confusion #30645

@johnlanni

Description

@johnlanni

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

  1. Create two Matrix rooms each with exactly 2 members (bot + same user)
  2. Mark only one as a DM in your Matrix client
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions