fix(discord): auto-thread explicit mentions in free-response channels - #32530
Open
husan42 wants to merge 1 commit into
Open
fix(discord): auto-thread explicit mentions in free-response channels#32530husan42 wants to merge 1 commit into
husan42 wants to merge 1 commit into
Conversation
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the focused Discord routing fix. The direct bot-mention case addresses behavior still present on current main at plugins/platforms/discord/adapter.py:6223.
Problems
- The new role regex (
plugins/platforms/discord/adapter.py:4510in this PR) accepts any leading<@&…>role mention. It does not verify that the role belongs to the bot, so an unrelated role mention would be stripped and would force an auto-thread in a free-response channel. - This changes a documented contract without a documentation update:
website/docs/user-guide/messaging/discord.md:377says free-response channels skip auto-threading, while lines 383-385 describe them as bypassing it.
Suggested changes
- Identify role invocations from the bot member's guild roles, then add a regression test for an unrelated leading role mention.
- Update the Discord guide if the explicit-mention exception is accepted.
Automated hermes-sweeper review.
| stripped_role_content = re.sub(r"^(?:<@&\d+>\s*)+", "", normalized_content).strip() | ||
| if stripped_role_content != normalized_content: | ||
| mention_prefix = True | ||
| normalized_content = stripped_role_content |
Contributor
There was a problem hiding this comment.
This matches every leading role mention, not a role associated with this bot. Please derive the bot member's role IDs in the message guild and only treat an intersection with the leading mentioned role IDs as an explicit Hermes invocation; otherwise an unrelated @role is stripped and forces a thread.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
DISCORD_FREE_RESPONSE_CHANNELSintentionally keeps unmentioned casual chat inline, but it also skipped auto-threading for explicit invocations. This meant that a channel configured for free response would not open a thread even when the user explicitly mentioned the bot or the bot role.Fix
Free-response channels now skip auto-threading only for unmentioned messages. Explicit bot mentions and leading role mentions are treated as deliberate bot conversations, so they can auto-thread unless the channel is explicitly configured in
DISCORD_NO_THREAD_CHANNELS.Related work
Related to #26058, but intentionally narrower: this preserves inline replies for unmentioned free-response messages while allowing explicit bot/role invocations to auto-thread. It does not make
free_response_channelsandauto_threadfully orthogonal by default.Test Plan
venv/bin/python -m pytest tests/gateway/test_discord_free_response.py tests/gateway/test_discord_slash_commands.py tests/e2e/test_discord_adapter.py -q