Skip to content

fix(discord): auto-thread explicit mentions in free-response channels - #32530

Open
husan42 wants to merge 1 commit into
NousResearch:mainfrom
husan42:fix/discord-free-response-explicit-mentions
Open

fix(discord): auto-thread explicit mentions in free-response channels#32530
husan42 wants to merge 1 commit into
NousResearch:mainfrom
husan42:fix/discord-free-response-explicit-mentions

Conversation

@husan42

@husan42 husan42 commented May 26, 2026

Copy link
Copy Markdown

Summary

  • allow explicit bot mentions in Discord free-response channels to create auto-threads
  • treat leading role mentions as explicit invocations and strip them from the prompt text
  • isolate Discord channel-related environment variables in affected tests

Problem

DISCORD_FREE_RESPONSE_CHANNELS intentionally 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_channels and auto_thread fully 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

@alt-glitch alt-glitch added type/bug Something isn't working platform/discord Discord bot adapter comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists labels May 26, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:4510 in 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:377 says 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists platform/discord Discord bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants