fix(discord): auto-thread cluster — free-response + reply + fallback + mention-name-strip - #11629
Merged
Conversation
Free-response channels already bypassed the @mention gate so users could chat inline with the bot, but auto-threading still fired on every message — spinning off a thread per message and defeating the lightweight-chat purpose. Fix: fold `is_free_channel` into `skip_thread` so threading is skipped whenever the channel is in DISCORD_FREE_RESPONSE_CHANNELS (via env or discord.free_response_channels in config.yaml). Net change: one line in _handle_message + one regression test. Partially addresses #9399. Authored by @Hypn0sis (salvaged from PR #9650; the bundled 'smart' auto-thread mode from that PR was dropped in favor of deterministic true/false semantics).
Previously a message like `<@&1490963422786093149> help` would spawn a thread literally named `<@&1490963422786093149> help`, exposing raw Discord mention markers in the thread list. Only user mentions (`<@id>`) were being stripped upstream — role mentions (`<@&id>`) and channel mentions (`<#id>`) leaked through. Fix: strip all three mention patterns in `_auto_create_thread` before building the thread name. Collapse runs of whitespace left by the removal. If the entire content was mention-only, fall back to 'Hermes' instead of an empty title. Fixes #6336. Tests: two new regression guards in test_discord_slash_commands.py covering mixed-mention content and mention-only content.
This was referenced Apr 17, 2026
13 tasks
1 task
This was referenced Jun 4, 2026
13 tasks
This was referenced Aug 2, 2026
Open
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.
Unified salvage of three complementary PRs plus one of our own fixes, all addressing overlapping issues in Discord auto-threading. Determinism preserved — no new config modes, just bug fixes.
Fixes #9399, fixes #8487, fixes #6336.
What this fixes
message.create_thread()direct call rejects<@&id>/<#id>markersCommits (authorship preserved for each salvaged fix)
4933f7a0— fix(discord): free-response channels skip auto-threading (@Hypn0sis, salvaged from PR fix(discord): implement smart auto-thread mode, free-response channels skip threading #9650; the bundledauto_thread: smartmode from that PR was dropped in favor of deterministic true/false — no new config modes)95b43c17— fix(discord): skip auto-threading reply messages + config.extra fallback for require_mention / free_response_channels (@OwenYWT, from PR fix(discord): skip auto-threading reply messages #9624)c57a0052— fix(discord): fall back when auto-thread creation fails (@sgaofen, from PR fix(discord): add auto-thread fallback path #8692 — channel.send + seed.create_thread when direct path rejects)d94f7cab— fix(discord): strip mention syntax from auto-thread names (ours — closes Discord auto-thread names show raw role mention IDs #6336)d9a66e0c— chore(release): map @Hypn0sis and @OwenYWT to AUTHOR_MAPTests
New regression cases added by the cherry-picks + our follow-ups:
test_discord_free_channel_skips_auto_thread(from fix(discord): implement smart auto-thread mode, free-response channels skip threading #9650)test_discord_reply_message_skips_auto_thread(from fix(discord): skip auto-threading reply messages #9624)test_discord_free_response_channel_can_come_from_config_extra(from fix(discord): skip auto-threading reply messages #9624)test_auto_create_thread_falls_back_to_seed_message(from fix(discord): add auto-thread fallback path #8692)test_auto_create_thread_returns_none_when_direct_and_fallback_fail(from fix(discord): add auto-thread fallback path #8692)test_auto_create_thread_strips_mention_syntax_from_name(ours — Discord auto-thread names show raw role mention IDs #6336)test_auto_create_thread_falls_back_to_hermes_when_only_mentions(ours — Discord auto-thread names show raw role mention IDs #6336 edge case)pytest tests/gateway/ -k discord→ 244/244 passed.E2E validation (real discord.py 2.7.1)
Verified live:
<@&id>,<@id>,<#id>—<@&1490963422786093149> <@555> please help <#123>→please helpHermesdefaultmessage.create_thread()raise → fallback viachannel.send()+seed.create_thread()with proper reason stringconfig.extra['free_response_channels']list read correctly without env varconfig.extraunsetNot addressed by this PR (separate concerns)
auto_thread: smartmode from PR fix(discord): implement smart auto-thread mode, free-response channels skip threading #9650 — dropped. Determinism over niche mode switches; can be added later if a user makes a concrete case.