Skip to content

feat(discord): allow auto-thread in free-response channels - #19131

Closed
stoicborg wants to merge 1 commit into
NousResearch:mainfrom
stoicborg:feat/discord-free-response-auto-thread
Closed

feat(discord): allow auto-thread in free-response channels#19131
stoicborg wants to merge 1 commit into
NousResearch:mainfrom
stoicborg:feat/discord-free-response-auto-thread

Conversation

@stoicborg

@stoicborg stoicborg commented May 3, 2026

Copy link
Copy Markdown

What

Adds an opt-in auto_thread_in_free_response_channels setting so that free-response channels can still benefit from auto-thread isolation.

Problem

Currently, free_response_channels implicitly disables auto-thread because the skip_thread check includes is_free_channel. This means private servers (where all channels are free-response and no mention is required) lose per-conversation thread isolation entirely.

Use Case: Private Discord Servers

This feature is designed for small, private Discord servers where:

  • The bot responds without requiring @mentions (via free_response_channels: "*")
  • Multiple topics are discussed in the same channel throughout the day
  • Without thread isolation, all conversations share one flat context stream, causing:
    • Earlier topics to leak into later conversations (context pollution)
    • The model to hallucinate connections between unrelated discussions
    • Long, noisy message histories that hurt attention quality
    • Faster token burn: every new message carries the baggage of all prior conversations in that channel

Example: In a #general channel, you ask the bot about coding at 9am, then about trip planning at 2pm. Without threads, the 2pm trip response is contaminated by the 9am coding context. With auto_thread_in_free_response_channels: true, each interaction spins up its own thread, keeping contexts clean and isolated while reducing long-context token consumption.

Solution

  • Introduce discord.auto_thread_in_free_response_channels in config.yaml
  • Also read from DISCORD_AUTO_THREAD_IN_FREE_RESPONSE_CHANNELS env var (env takes precedence)
  • Default: false — existing behaviour is preserved; free-response channels skip auto-thread
  • When true: auto-thread fires independently of the free-response setting
  • Users who want no threads in specific free-response channels can still use no_thread_channels

Why opt-in instead of changing the default?

Some existing users rely on free-response channels producing flat, non-threaded replies. Changing the default would break their UI expectations.

Example Config

discord:
  free_response_channels: "*"
  auto_thread: true
  auto_thread_in_free_response_channels: true

Files Changed

  • gateway/platforms/discord.py — check new env var before deciding skip_thread
  • gateway/config.py — bridge config.yaml key to env var

Previously `free_response_channels` implicitly disabled auto-thread
because `skip_thread` included `or is_free_channel`. This prevented
small private servers (where mention requirements are relaxed via
`free_response_channels: "*"`) from benefiting from per-conversation
thread isolation.

Remove the `is_free_channel` condition from `skip_thread` so that
auto-thread and free-response are orthogonal features. Users who want
no threads in specific free-response channels can still use
`no_thread_channels`.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/discord Discord bot adapter comp/gateway Gateway runner, session dispatch, delivery labels May 3, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #17564 and #18455 — same feature: opt-in auto-thread for free-response channels. Please coordinate to avoid merge conflicts.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #17564 and #18455 — same feature: opt-in auto-thread for free-response channels. Please coordinate to avoid merge conflicts.

@stoicborg

stoicborg commented May 3, 2026

Copy link
Copy Markdown
Author

Closing in favor of #18455.

I arrived at the same design and submitted this PR, but #18455 (by @FunJim) covers the same feature more completely — including tests, docs, additional config plumbing, and a well-justified default-behavior analysis. No need for duplicate implementations.

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 P3 Low — cosmetic, nice to have 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