Skip to content

feat(discord): allow opt-in auto-threading for free-response channels - #27969

Closed
0xjackyang wants to merge 1 commit into
NousResearch:mainfrom
0xjackyang:pr/discord-auto-thread-free-response-opt-in
Closed

0xjackyang wants to merge 1 commit into
NousResearch:mainfrom
0xjackyang:pr/discord-auto-thread-free-response-opt-in

Conversation

@0xjackyang

Copy link
Copy Markdown
Contributor

Problem

discord.free_response_channels lets operators turn off the mention
requirement for designated channels so the bot responds inline. Today
free-response → inline-only is treated as doctrine
(#12728, fix(discord): keep free-response channels inline,
fix(discord): free-response channels skip auto-threading).

For some real deployments that's the wrong default. Consider a "lounge"
or "sandbox" channel where the bot is conversational without mention,
but each user turn benefits from being isolated in its own thread —
concurrent users don't talk over each other's tool calls, and per-thread
context stays clean. The current path to get that requires reverting to
require_mention=true, which defeats the point of free-response.

Fix

Add an opt-in YAML key discord.auto_thread_free_response_channels
(+ matching DISCORD_AUTO_THREAD_FREE_RESPONSE_CHANNELS env var).
Defaults to empty / off → existing "free-response = inline" behavior is
preserved for every existing operator. When a parent channel is listed,
that channel still auto-threads on each user-initiated turn while
remaining free-response (no mention required).

Supports * wildcard, same convention as allowed_channels.

Refactor (small, isolated)

Extracts Discord channel-id parsing into _parse_discord_channel_set
which accepts str / list / tuple / set / frozenset / scalar (including
YAML bare numerics like 1491973769726791812). This is a strict
superset of the existing _discord_free_response_channels parser and
incidentally subsumes the recent bare-numeric coercion fix.

_discord_channel_set_from_env_or_config(env_var, config_key)
consolidates the env-takes-precedence-over-config pattern used by every
channel-id config.

Test

test_free_response_channel_can_auto_thread_when_configured covers the
new behavior: with DISCORD_FREE_RESPONSE_CHANNELS=789 and
DISCORD_AUTO_THREAD_FREE_RESPONSE_CHANNELS=789, a message arriving in
channel 789 auto-creates a thread before being handled.

Scope

3 files. Default behavior unchanged for every existing operator. No
config schema change beyond one new opt-in key.

Adds opt-in DISCORD_AUTO_THREAD_FREE_RESPONSE_CHANNELS / discord.auto_thread_free_response_channels.
Default empty → existing free-response=inline behavior preserved.
Refactors channel-id parsing into a single helper that handles str/list/scalar
including YAML bare numerics (subsumes the recent bare-numeric coercion fix).
@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter P2 Medium — degraded but workaround exists labels May 18, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Competes with existing cluster: #17564 (feat: threaded free-response channels), #19131 (same feature, closed), #26074 (decouple auto_thread from free_response), #27651 (same override, marked dupe of #13958). Consider consolidating — #26074 is the most recent active contender with a different approach (skip-thread env var vs. new channel list).

@0xjackyang

Copy link
Copy Markdown
Contributor Author

Thanks for the cluster pointer @alt-glitch. Closing in favor of #17564 — same approach (preserve current inline default, add explicit per-channel opt-in for auto-thread on free-response channels). No need to maintain two duplicate PRs for the same direction.

Will add support on #17564.

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.

2 participants