hermes - ✅(Solved) Fix Discord known-thread participation bypass cannot be disabled [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#16725Fetched 2026-04-28 06:51:13
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×1referenced ×1

Root Cause

In gateway/platforms/discord.py::_handle_message, the known-thread check is unconditional:

in_bot_thread = is_thread and thread_id in self._threads

if require_mention and not is_free_channel and not in_bot_thread:
    ...

The thread participation behavior itself exists intentionally, but there is no supported configuration switch to disable this bypass for deployments that want strict per-message mention gating.

Fix Action

Fix / Workaround

  • known Discord thread + require mention + strict mode + no mention => message is not dispatched
  • config extra can enable strict mode
  • YAML config bridges to env without overriding an existing env var
  • default behavior stays backward-compatible

PR fix notes

PR #16722: feat(discord): add strict mention mode

Description (problem / solution / changelog)

Summary

  • add discord.strict_mention / DISCORD_STRICT_MENTION to mirror Slack's accepted strict-mention pattern
  • default to the current Discord behavior (strict_mention: false): previously participated threads can continue without repeated mentions
  • when strict_mention: true, require an explicit Discord bot mention for every server channel/thread message unless the channel is free-response
  • bridge the YAML config key into adapter config and env state without overriding an existing env var
  • document the new Discord option and add regression coverage for multi-bot strict routing

Background

Discord already tracked threads where the bot participated and used that state to skip mention checks for follow-up messages. That behavior was unconditional. This PR keeps it as the default for backward compatibility, while adding the same style of opt-in strict mode that Slack added in #16193 after #8019.

This matters for multi-bot / multi-agent Discord servers: explicit mentions should be able to route a turn to one bot without waking another bot just because it participated earlier in the same thread.

Closes #16725

Behavior matrix

ContextDefault (strict_mention: false)strict_mention: true
DMRespondsResponds
Free-response channelRespondsResponds
Channel/thread, explicit @mentionRespondsResponds
Previously participated thread, no mentionRespondsIgnores until re-mentioned
Unknown thread/channel, no mentionIgnoresIgnores

Test Plan

  • /root/.hermes/hermes-agent/venv/bin/python -m pytest tests/gateway/test_discord_free_response.py tests/gateway/test_config.py tests/gateway/test_discord_thread_persistence.py tests/gateway/test_discord_channel_controls.py -q
  • /root/.hermes/hermes-agent/venv/bin/python -m pytest tests/gateway/test_discord_free_response.py tests/gateway/test_config.py tests/gateway/test_discord_thread_persistence.py tests/gateway/test_discord_channel_controls.py tests/gateway/test_slack_mention.py -q

Changed files

  • gateway/config.py (modified, +11/-0)
  • gateway/platforms/discord.py (modified, +34/-5)
  • hermes_cli/config.py (modified, +1/-0)
  • tests/conftest.py (modified, +1/-0)
  • tests/gateway/test_config.py (modified, +34/-0)
  • tests/gateway/test_discord_free_response.py (modified, +60/-0)
  • website/docs/user-guide/messaging/discord.md (modified, +18/-2)

Code Example

in_bot_thread = is_thread and thread_id in self._threads

if require_mention and not is_free_channel and not in_bot_thread:
    ...
RAW_BUFFERClick to expand / collapse

Bug Description

Discord server/channel messages normally respect mention gating when discord.require_mention: true / DISCORD_REQUIRE_MENTION=true. However, messages inside a thread previously handled by the bot bypass the mention requirement unconditionally because the adapter treats any tracked thread as an active bot thread.

This makes mention-gated Discord deployments unexpectedly process unmentioned messages in existing threads after the bot has participated there.

This is especially disruptive in multi-bot / multi-agent Discord channels: once one bot has participated in a thread, later messages intended for another bot (or for humans) can still wake the first bot. Bots can then interrupt each other, create cross-talk, and derail coordinated multi-agent workflows where explicit mentions are supposed to route turns to the right agent.

Root Cause

In gateway/platforms/discord.py::_handle_message, the known-thread check is unconditional:

in_bot_thread = is_thread and thread_id in self._threads

if require_mention and not is_free_channel and not in_bot_thread:
    ...

The thread participation behavior itself exists intentionally, but there is no supported configuration switch to disable this bypass for deployments that want strict per-message mention gating.

Expected Behavior

Mention-gated Discord deployments should be able to enable a strict mode so that an unmentioned message in a previously participated thread is ignored unless:

  • the message explicitly mentions the bot,
  • the channel/thread is configured for free response, or
  • another explicit allow path applies.

In multi-bot channels, this allows explicit mentions to remain the routing mechanism and prevents bots from responding to messages addressed to a different bot.

Actual Behavior

If the thread ID is present in ~/.hermes/discord_threads.json / adapter._threads, the message is processed even without mentioning the bot.

In multi-bot setups, that means a bot can keep responding in an already-known thread even when the user is trying to talk to another bot, causing agent-to-agent interruption and noisy cross-talk.

Proposed Fix

Add an opt-in strict mention config, matching the Slack pattern from #16193 / #8019:

  • discord.strict_mention
  • DISCORD_STRICT_MENTION

Default should preserve existing behavior (false), while true should enforce mention gating even in known threads.

Also bridge the YAML key through gateway config so platform adapter config and env behavior stay consistent.

Regression Coverage

Add tests for:

  • known Discord thread + require mention + strict mode + no mention => message is not dispatched
  • config extra can enable strict mode
  • YAML config bridges to env without overriding an existing env var
  • default behavior stays backward-compatible

Related

Fix PR: #16722 Related Slack precedent: #8019 / #16193 Related historical PR introducing persisted Discord thread participation: #1661

extent analysis

TL;DR

To fix the issue, add an opt-in strict mention config, discord.strict_mention or DISCORD_STRICT_MENTION, and set it to true to enforce mention gating even in known threads.

Guidance

  • The proposed fix involves adding a new configuration option to enable strict mention gating, which can be done by setting discord.strict_mention or DISCORD_STRICT_MENTION to true.
  • To verify the fix, test the behavior with a known Discord thread, require_mention enabled, and strict_mention enabled, ensuring that unmentioned messages are not dispatched.
  • The existing behavior can be preserved by keeping the strict_mention config set to false (default).
  • To mitigate the issue in multi-bot setups, consider using explicit mentions to route messages to the intended bot.

Example

# Example of the proposed fix in discord.py
if require_mention and not is_free_channel and not (in_bot_thread and discord.strict_mention):
    # Ignore message if not mentioned and strict mention is enabled
    return

Notes

The fix relies on the introduction of a new configuration option, which may require updates to the existing codebase and configuration files.

Recommendation

Apply the workaround by setting discord.strict_mention or DISCORD_STRICT_MENTION to true to enable strict mention gating, as this provides a clear and explicit way to control the behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix Discord known-thread participation bypass cannot be disabled [1 pull requests, 1 participants]