Skip to content

feat(discord): add thread_require_mention for multi-bot threads (salvage #25313)#25445

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-fd945ffb
May 14, 2026
Merged

feat(discord): add thread_require_mention for multi-bot threads (salvage #25313)#25445
teknium1 merged 2 commits into
mainfrom
hermes/hermes-fd945ffb

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #25313 (@simpolism) — adds opt-in discord.thread_require_mention so multi-bot Discord threads stop firing every bot on every message.

Changes

  • gateway/platforms/discord.py: new _discord_thread_require_mention() helper; in_bot_thread shortcut ANDs with not self._discord_thread_require_mention() so when enabled, threads gate on @mention like channels.
  • gateway/config.py: yaml→env bridge for discord.thread_require_mention (env wins over yaml, mirrors existing require_mention).
  • hermes_cli/config.py: thread_require_mention: False in DEFAULT_CONFIG.
  • Tests: 4 adapter tests (default keeps shortcut / enabled gates / enabled+mentioned still passes / via config.extra) + 2 config-bridge tests. Adapter fixture also now clears 7 DISCORD_* env vars on entry so the file isn't fragile to contributor shell state.
  • Docs: env-var table row, YAML example, prose section, cross-link from auto_thread.
  • scripts/release.py: AUTHOR_MAP entry for jake@nousresearch.comsimpolism.

Default is false — existing 1:1 deployments unchanged.

Validation

Result
tests/gateway/test_discord_free_response.py + test_config.py 70/70 pass
Cherry-pick onto current main clean (1 trivial auto-merge in hermes_cli/config.py)

Closes #25313. Fixes #25312.

simpolism and others added 2 commits May 13, 2026 22:19
By default, once Hermes participates in a Discord thread (auto-created on
@mention or replied in once) it auto-responds to every subsequent message
in that thread without requiring further @mentions. That's the right default
for one-on-one conversations and isolated channel threads.

But it's a confirmed footgun in multi-bot threads. When a user invokes one
bot per turn — addressing Codex first, then Hermes — every other bot in the
thread also fires on every message, burning credits and spamming the channel.
Author has hit this personally in active multi-bot research-team threads.

Add a new `discord.thread_require_mention` config key (env:
`DISCORD_THREAD_REQUIRE_MENTION`), default `false` to preserve existing
behavior. When `true`, the in-thread mention shortcut is disabled and
threads are gated the same way channels are. Explicit @mentions still pass
through as expected.

Mirrors the existing helper shape (config.extra > env > default) and the
existing yaml→env bridge pattern used by `require_mention`.

Changes:

- gateway/platforms/discord.py: new `_discord_thread_require_mention()`
  helper; in_bot_thread shortcut now AND's with `not _discord_thread_require_mention()`
- gateway/config.py: bridge `discord.thread_require_mention` from config.yaml
  to `DISCORD_THREAD_REQUIRE_MENTION` env var (mirrors the existing
  `require_mention` bridge two lines above)
- hermes_cli/config.py: add `thread_require_mention: False` default to
  DEFAULT_CONFIG['discord']
- tests/gateway/test_discord_free_response.py: 4 new tests covering default
  behaviour (in-thread shortcut still works), enabled behaviour (mention
  required in threads), enabled+mentioned (mention still passes through),
  and yaml-via-config.extra path. Also clears DISCORD_* env vars in the
  `adapter` fixture so process-env state from the contributor's shell
  doesn't leak into per-test behaviour.
- tests/gateway/test_config.py: 2 new tests covering the yaml→env bridge
  (both the apply-from-yaml and env-precedence-over-yaml paths)
- website/docs/user-guide/messaging/discord.md: document the new env var
  + config key with multi-bot rationale; cross-link from `auto_thread`
  section

Tested on Ubuntu 24.04.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-fd945ffb 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: 8308 on HEAD, 8308 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4376 pre-existing issues carried over.

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

@teknium1 teknium1 merged commit ffbc211 into main May 14, 2026
16 of 17 checks passed
@teknium1 teknium1 deleted the hermes/hermes-fd945ffb branch May 14, 2026 05:21
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter labels May 14, 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/discord Discord bot adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Opt-in DISCORD_THREAD_REQUIRE_MENTION for multi-bot threads

3 participants