Nothing open on GitHub. Fix merged in #28580 on 19 May 2026. Check it covers your case.
The short answer
0open issues
0open PRs
3items grouped
- Known?
- Yes. 3 related items grouped here, 1 issue already closed.
- Fix event
- A fix was merged to main in PR #28580. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
resolved, deciding PR #28580. That is separate from the fix event. - Still open
- Nothing open on GitHub.
A bug where MATRIX_AUTO_THREAD causes infinite reply loops when multiple bots share a Matrix room, along with a proposed fix using a thread_require_mention option to prevent this behavior.
Open issues0
Open PRs0
Fixes on record
-
#28580 fix(matrix): implement thread_require_mention to prevent multi-agent reply loops (#27996)
files:
gateway/platforms/matrix.pyShow the diff
-
gateway/platforms/matrix.py@@ -380,6 +380,7 @@ def __init__(self, config: PlatformConfig): self._require_mention: bool = os.getenv( "MATRIX_REQUIRE_MENTION", "true" ).lower() not in {"false", "0", "no"} + self._thread_require_mention: bool = self._parse_thread_require_mention(config) free_rooms_raw = config.extra.get("free_response_rooms") if free_rooms_raw is None: free_rooms_raw = os.getenv("MATRIX_FREE_RESPONSE_ROOMS", "") @@ -468,6 +469,27 @@ def _is_duplicate_event(self, event_id) -> bool: self._processed_events_set.add(event_id) return False + @staticmethod + def _parse_thread_require_mention(config) -> bool: + """Parse thread_require_mention from config.extra or env var. + + Handles both YAML booleans and string values (``\"true\"``, ``\"false\"``, + ``\"yes\"``, ``\"no\"``, ``\"on\"``, ``\"off\"``, ``\"1\"``, ``\"0\"``). + Falls back to ``MATRIX_THREAD_REQUIRE_MENTION`` env var, default ``false``. + Mirrors Discord adapter's parsing pattern. + """ + configured = config.extra.get("thread_require_mention") + if configured is not None: + if isinstance(configured, bool): + return configured + if isinstance(configured, str): + return configured.lower() not in {"false", "0", "no", "off"} + # int, float, etc. — truthiness fallback + return bool(configured) + return os.getenv( + "MATRIX_THREAD_REQUIRE_MENTION", "false" + ).lower() in {"true", "1", "yes", "on"} + # ------------------------------------------------------------------ # E2EE helpers # ------------------------------------------------------------------ @@ -1701,6 +1723,21 @@ async def _resolve_message_context( ) return None + # Thread-level @mention gating: even in a bot-participated thread, + # require @mention when thread_require_mention is enabled. + # Prevents infinite reply loops in multi-agent shared rooms + # where multiple bots all participate in the same thread. + elif (self._thread_require_mention and in_bot_thread + and not is_free_room): + if not is_mentioned: + logger.debug( + "Matrix: ignoring message %s in thread %s — " + "no @mention (thread_require_mention=true)", + event_id, + thread_id, + ) + return None + # DM mention-thread. if is_dm and not thread_id and self._dm_mention_threads and is_mentioned: thread_id = event_id
-
1 PR closed without merging
From the close comments: merged via another change 1
-
#27996 fix(matrix): implement thread_require_mention to prevent multi-agent reply loops · merged via another change →
276e6cc,#28580
Closed issues · 1
- Closed#27995bug: MATRIX_AUTO_THREAD enables infinite reply loops when multiple bots share a Matrix room
How this cluster was grouped
-
Link evidence (
structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference. -
Pairwise link density
0.67: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Merged PRs
- #28580
- Closed issues
- 1
- Attempts
- 1 PR closed without merging
- Fix link checked
- 19 May 2026