Skip to content

fix(matrix): implement thread_require_mention to prevent multi-agent reply loops (#27996)#28580

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-3ad7d98a
May 19, 2026
Merged

fix(matrix): implement thread_require_mention to prevent multi-agent reply loops (#27996)#28580
teknium1 merged 1 commit into
mainfrom
hermes/hermes-3ad7d98a

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #27996 by @justemu (squashed 2-commit stack).

What: Prevents reply loops in multi-agent shared Matrix rooms by adding an opt-in thread_require_mention filter — when enabled, bots only respond to @mentioned messages even inside threads they've previously participated in.

How: Mirrors Discord's adapter pattern. New _parse_thread_require_mention parser (YAML bool, string truthy, or MATRIX_THREAD_REQUIRE_MENTION env). In _resolve_message_context, the gate fires for bot-participated threads outside free-response rooms.

Original PR: #27996
Fixes #27995.

…reply loops

In multi-agent shared Matrix rooms, multiple bots all participating in the
same thread could trigger infinite reply loops — each bot's reply re-engaged
the others because they were all in the bot-thread set. Discord has a
`thread_require_mention` opt-in for this; Matrix didn't.

Add `_parse_thread_require_mention(config)` (mirrors Discord's pattern).
In `_resolve_message_context`, when enabled and the message is in a
bot-participated thread (not a free-response room), require @mention
before processing.

Salvage of @justemu's 2-commit stack (#27996). Fixes #27995.
@teknium1 teknium1 merged commit 276e6cc into main May 19, 2026
4 checks passed
@teknium1 teknium1 deleted the hermes/hermes-3ad7d98a branch May 19, 2026 07:04
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-3ad7d98a vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8952 on HEAD, 8952 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4702 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/matrix Matrix adapter (E2EE) labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/matrix Matrix adapter (E2EE) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MATRIX_AUTO_THREAD enables infinite reply loops when multiple bots share a Matrix room

3 participants