-
-
Notifications
You must be signed in to change notification settings - Fork 69.3k
Matrix: 2-member rooms incorrectly routed as DMs to main session #7718
Description
Description
Matrix rooms with exactly 2 members (user + bot) are being classified as DMs and routed to the main session instead of getting their own isolated group session.
Expected Behavior
A Matrix room (not a DM) should always route to its own session with key agent:main:matrix:channel:<roomId>, regardless of member count.
Actual Behavior
The isDirectMessage check in extensions/matrix/src/matrix/monitor/direct.ts has an aggressive heuristic:
const memberCount = await resolveMemberCount(roomId);
if (memberCount === 2) {
log(`matrix: dm detected via member count room=${roomId} members=${memberCount}`);
return true;
}This causes 2-member rooms to be treated as DMs, routing them to the main session (agent:main:main) instead of creating a separate room session.
Reproduction
- Create a Matrix room (not a DM)
- Invite only the bot (2 total members: you + bot)
- Send a message in the room
- Observe it arrives in the main session (shared with DMs, WhatsApp, etc.) instead of an isolated room session
Impact
- Context bleeds between Matrix rooms and DMs
- Private room conversations visible in main session history
- No isolation for 2-member rooms
Suggested Fix
The member count heuristic should be removed or made opt-in. Rooms should be distinguished from DMs using Matrix's actual DM indicators (m.direct account data, is_direct state) rather than member count.
Alternatively, add a config option like channels.matrix.strictDmDetection: true to disable the member count heuristic.
Environment
- OpenClaw version: 2026.1.29
- Matrix plugin: bundled (extensions/matrix)
- Homeserver: Synapse (self-hosted)