Skip to content

The agent that grows with you

docs(matrix): surface the DM-classification bypass in the operator-facing docs

chelsealonge23a033e85fd
diff --git a/tests/plugins/platforms/matrix/test_dm_classification_doc.py b/tests/plugins/platforms/matrix/test_dm_classification_doc.py
index 470f0b153ab..47b4dff09e9 100644
--- a/tests/plugins/platforms/matrix/test_dm_classification_doc.py
+++ b/tests/plugins/platforms/matrix/test_dm_classification_doc.py
@@ -1,10 +1,22 @@
"""The module docstring documents env vars near MATRIX_ALLOWED_ROOMS/MATRIX_REQUIRE_MENTION/
MATRIX_AUTO_THREAD as if they applied uniformly to rooms, but _resolve_room_identity classifies
any room with <=2 joined members as a DM regardless of m.direct or an explicit room name, which
-silently bypasses those settings (#114733). Assert the docstring actually says so."""
+silently bypasses those settings (#114733). Assert the docstring actually says so.
+
+Issue #114733 says this behavior "is not surfaced anywhere a user would reasonably
+encounter it" and specifically asks for a callout wherever MATRIX_ALLOWED_ROOMS,
+MATRIX_FREE_RESPONSE_ROOMS, MATRIX_REQUIRE_MENTION, and MATRIX_AUTO_THREAD are
+documented for operators — i.e. the env-var reference table and the Matrix user
+guide, not just the adapter's source docstring. Assert those two operator-facing
+docs carry the same callout.
+"""
+
+from pathlib import Path
from plugins.platforms.matrix import adapter
+REPO_ROOT = Path(__file__).resolve().parents[4]
+
def test_module_docstring_covers_member_count_dm_classification():
doc = adapter.__doc__
@@ -14,3 +26,28 @@ def test_module_docstring_covers_member_count_dm_classification():
assert "MATRIX_FREE_RESPONSE_ROOMS" in doc.split("Note:", 1)[1]
assert "MATRIX_REQUIRE_MENTION" in doc.split("Note:", 1)[1]
assert "MATRIX_DM_AUTO_THREAD" in doc.split("Note:", 1)[1]
+
+
+def test_env_var_reference_covers_dm_classification_bypass():
+ text = (REPO_ROOT / "website/docs/reference/environment-variables.md").read_text()
+
+ for var in (
+ "MATRIX_ALLOWED_ROOMS",
+ "MATRIX_REQUIRE_MENTION",
+ "MATRIX_FREE_RESPONSE_ROOMS",
+ "MATRIX_AUTO_THREAD",
+ ):
+ row = next(line for line in text.splitlines() if line.startswith(f"| `{var}` |"))
+ assert "2 or fewer joined members" in row, f"{var} row missing the DM-classification callout"
+
+
+def test_matrix_user_guide_covers_dm_classification_bypass():
+ text = (REPO_ROOT / "website/docs/user-guide/messaging/matrix.md").read_text()
+
+ dms_row = next(line for line in text.splitlines() if line.startswith("| **DMs**"))
+ rooms_row = next(line for line in text.splitlines() if line.startswith("| **Rooms**"))
+
+ assert "2 or fewer joined members" in dms_row
+ assert "MATRIX_ALLOWED_ROOMS" in rooms_row
+ assert "MATRIX_REQUIRE_MENTION" in rooms_row
+ assert "MATRIX_FREE_RESPONSE_ROOMS" in rooms_row
diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.md
index a91adb2bc75..2a0a660c0f0 100644
--- a/website/docs/reference/environment-variables.md
+++ b/website/docs/reference/environment-variables.md
@@ -521,19 +521,19 @@ These are set automatically by the Docker terminal backend when `proxy.enabled:
| `MATRIX_ALLOW_ALL_USERS` | Allow any Matrix user to trigger the bot (dev only). |
| `MATRIX_HOME_CHANNEL` | Default room ID for cron / notification delivery. |
| `MATRIX_HOME_CHANNEL_NAME` | Display name for the Matrix home room. |
-| `MATRIX_ALLOWED_ROOMS` | Comma-separated Matrix room IDs allowed to trigger bot responses |
+| `MATRIX_ALLOWED_ROOMS` | Comma-separated Matrix room IDs allowed to trigger bot responses. Does not apply to rooms auto-classified as DMs (any room with 2 or fewer joined members, regardless of name) — those always respond. |
| `MATRIX_HOME_ROOM` | Room ID for proactive message delivery (e.g. `!abc123:matrix.org`) |
| `MATRIX_ENCRYPTION` | Enable end-to-end encryption (`true`/`false`, default: `false`) |
| `MATRIX_E2EE_MODE` | Matrix E2EE behavior: `off`, `optional`, or `required`. Overrides `MATRIX_ENCRYPTION` when set. |
| `MATRIX_DEVICE_ID` | Stable Matrix device ID for E2EE persistence across restarts (e.g. `HERMES_BOT`). Without this, E2EE keys rotate every startup and historic-room decrypt breaks. |
| `MATRIX_REACTIONS` | Enable processing-lifecycle emoji reactions on inbound messages (default: `true`). Set to `false` to disable. |
-| `MATRIX_REQUIRE_MENTION` | Require `@mention` in rooms (default: `true`). Set to `false` to respond to all messages. |
-| `MATRIX_FREE_RESPONSE_ROOMS` | Comma-separated room IDs where bot responds without `@mention` |
+| `MATRIX_REQUIRE_MENTION` | Require `@mention` in rooms (default: `true`). Set to `false` to respond to all messages. A room with 2 or fewer joined members is auto-classified as a DM and never requires a mention, regardless of this setting — add a third member if you need a deliberately-2-person room to behave like a regular room. |
+| `MATRIX_FREE_RESPONSE_ROOMS` | Comma-separated room IDs where bot responds without `@mention`. Rooms auto-classified as DMs (2 or fewer joined members) already respond without a mention and ignore this list. |
| `MATRIX_IGNORE_USER_PATTERNS` | Comma-separated regular expressions for Matrix bridge/appservice ghost user IDs to ignore |
| `MATRIX_PROCESS_NOTICES` | Process inbound Matrix `m.notice` events (default: `false`) |
| `MATRIX_SESSION_SCOPE` | Matrix session scope for project rooms: `auto`, `room`, or `thread` (default: `auto`) |
| `MATRIX_ALLOW_ROOM_MENTIONS` | Allow outbound `@room` mentions to notify all room members (default: `false`) |
-| `MATRIX_AUTO_THREAD` | Auto-create threads for room messages (default: `true`) |
+| `MATRIX_AUTO_THREAD` | Auto-create threads for room messages (default: `true`). Does not apply to rooms auto-classified as DMs (2 or fewer joined members) — those follow `MATRIX_DM_AUTO_THREAD` instead. |
| `MATRIX_DM_AUTO_THREAD` | Auto-create threads for DM messages in Matrix (default: `false`) |
| `MATRIX_DM_MENTION_THREADS` | Create a thread when bot is `@mentioned` in a DM (default: `false`) |
| `MATRIX_APPROVAL_REQUIRE_SENDER` | Require approval/model-picker reactions to come from the original requester when known (default: `true`) |
diff --git a/website/docs/user-guide/messaging/matrix.md b/website/docs/user-guide/messaging/matrix.md
index cc17a72702c..aa110653de0 100644
--- a/website/docs/user-guide/messaging/matrix.md
+++ b/website/docs/user-guide/messaging/matrix.md
@@ -16,10 +16,10 @@ Before setup, here's the part most people want to know: how Hermes behaves once
| Context | Behavior |
|---------|----------|
-| **DMs** | Hermes responds to every message. No `@mention` needed. Each DM has its own session. Set `MATRIX_DM_MENTION_THREADS=true` to start a thread when the bot is `@mentioned` in a DM. |
-| **Rooms** | By default, Hermes requires an `@mention` to respond. Set `MATRIX_REQUIRE_MENTION=false` or add room IDs to `MATRIX_FREE_RESPONSE_ROOMS` for free-response rooms. Room invites are auto-accepted. |
+| **DMs** | Hermes responds to every message. No `@mention` needed. Each DM has its own session. Set `MATRIX_DM_MENTION_THREADS=true` to start a thread when the bot is `@mentioned` in a DM. Any room with 2 or fewer joined members is treated as a DM this way too, even if it has an explicit name — Matrix clients auto-name 1:1 chats, so name alone isn't a reliable signal. |
+| **Rooms** | By default, Hermes requires an `@mention` to respond. Set `MATRIX_REQUIRE_MENTION=false` or add room IDs to `MATRIX_FREE_RESPONSE_ROOMS` for free-response rooms. Room invites are auto-accepted. A deliberately-created 2-person room is still classified as a DM (see above) and silently bypasses `MATRIX_ALLOWED_ROOMS`, `MATRIX_REQUIRE_MENTION`, and `MATRIX_FREE_RESPONSE_ROOMS` — add a third member if you need it to behave like a regular room. |
| **Threads** | Hermes supports Matrix threads (MSC3440). If you reply in a thread, Hermes keeps the thread context isolated from the main room timeline. Threads where the bot has already participated do not require a mention. |
-| **Auto-threading** | By default, Hermes auto-creates a thread for each message it responds to in a room. This keeps conversations isolated. Set `MATRIX_AUTO_THREAD=false` to disable. Set `MATRIX_DM_AUTO_THREAD=true` (default false) to also auto-create threads for DM messages — this is distinct from `MATRIX_DM_MENTION_THREADS`, which only starts a thread when the bot is `@mentioned` in a DM. |
+| **Auto-threading** | By default, Hermes auto-creates a thread for each message it responds to in a room. This keeps conversations isolated. Set `MATRIX_AUTO_THREAD=false` to disable. Set `MATRIX_DM_AUTO_THREAD=true` (default false) to also auto-create threads for DM messages — this is distinct from `MATRIX_DM_MENTION_THREADS`, which only starts a thread when the bot is `@mentioned` in a DM. Rooms with 2 or fewer joined members are DM-classified (see above) and follow `MATRIX_DM_AUTO_THREAD`, not `MATRIX_AUTO_THREAD`. |
| **Commands** | Hermes accepts normal `/commands` when your Matrix client sends them. If your client reserves `/` for local commands, use `!commands` instead; Hermes normalizes known `!command` aliases to `/command`. |
| **Interactive controls** | Dangerous-command approval and `/model` selection can use Matrix reactions. Approval reactions can be limited to the user who requested the action. |
| **Thinking and tool activity** | Matrix uses threaded, editable thinking/tool-activity panes when gateway progress is enabled, so updates do not flood the main room timeline. |