Skip to content

fix(discord): keep free-response channels inline - #25311

Closed
simpolism wants to merge 1 commit into
NousResearch:mainfrom
simpolism:fix/discord-free-response-skip-auto-thread
Closed

fix(discord): keep free-response channels inline#25311
simpolism wants to merge 1 commit into
NousResearch:mainfrom
simpolism:fix/discord-free-response-skip-auto-thread

Conversation

@simpolism

Copy link
Copy Markdown
Contributor

What does this PR do?

Fix a code-vs-docs gap in Discord auto-threading. Free-response channels are documented as "skip auto-threading — reply inline," but the production code only checks DISCORD_NO_THREAD_CHANNELS when deciding whether to skip thread creation, not DISCORD_FREE_RESPONSE_CHANNELS. So every message in a free-response channel currently spawns its own thread, turning a documented "lightweight chat" channel into a thread-spawning machine.

One-line production change: OR is_free_channel into the existing skip_thread calculation.

The existing docstring for discord.free_response_channels at website/docs/user-guide/messaging/discord.md:347 already promises this behavior:

"Free-response channels also skip auto-threading — the bot replies inline rather than spinning off a new thread per message. This keeps the channel usable as a lightweight chat surface."

so no docs change is needed — this PR makes the code match the docs.

Related Issue

Fixes #25310

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/platforms/discord.py: in _handle_message's auto-thread block, skip_thread = bool(channel_ids & no_thread_channels) becomes bool(channel_ids & no_thread_channels) or is_free_channel. The is_free_channel variable is already computed earlier in the function (used by the mention gate) — this propagates it to the auto-thread gate as well.
  • tests/gateway/test_discord_free_response.py: new regression test test_discord_free_response_channel_skips_auto_thread that mocks _auto_create_thread and asserts it is not awaited when a message arrives in a free-response channel with auto_thread=true (the default).

How to Test

To verify the bug exists without the fix:

  1. Check out main.
  2. Apply only the test addition from this PR.
  3. Run pytest tests/gateway/test_discord_free_response.py::test_discord_free_response_channel_skips_auto_thread.
  4. Expect: failure with AssertionError: Expected mock to not have been awaited. Awaited 1 times. (i.e. the production bug is real — auto-thread is fired).

To verify the fix:

  1. Apply this full PR.
  2. Run the same test — passes.
  3. Run the full tests/gateway/test_discord_free_response.py suite — 22 tests pass (was 21).

Manual verification: configure a Discord bot with discord.free_response_channels: [<channel-id>] and discord.auto_thread: true. Send any message in that channel. Before this PR: bot spawns a thread. After this PR: bot replies inline.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs — no duplicate
  • My PR contains only changes related to this fix
  • I've run the impacted test files and all tests pass
  • I've added tests — regression test added that demonstrably fails without the fix
  • I've tested on my platform: Ubuntu 24.04

Documentation & Housekeeping

  • I've updated relevant documentation — N/A; existing docs already describe the intended behavior, this PR makes code match docs
  • cli-config.yaml.example — N/A, no config key changes
  • CONTRIBUTING.md / AGENTS.md — N/A, no architecture/workflow changes
  • Cross-platform impact — N/A, purely server-side adapter logic
  • Tool descriptions/schemas — N/A

Free-response channels are intended as lightweight chat surfaces — the bot
responds to every message without requiring an @mention. But the auto-thread
gate only checked DISCORD_NO_THREAD_CHANNELS, not DISCORD_FREE_RESPONSE_CHANNELS,
so every message in a free-response channel still spawned a brand-new thread.
That turns a chat channel into a thread-spawning machine: 1 thread per message.

The user-facing docs at website/docs/user-guide/messaging/discord.md already
describe the intended behavior ("Free-response channels also skip auto-threading
— the bot replies inline rather than spinning off a new thread per message"),
so this is a code-vs-docs gap, not a design change.

Fix: OR is_free_channel into skip_thread alongside the existing no_thread_channels
check. One-line production change.

Regression test added at tests/gateway/test_discord_free_response.py:
test_discord_free_response_channel_skips_auto_thread asserts that a message
in a free-response channel never calls _auto_create_thread.  Reverting the
one-line fix causes the test to fail with 'Expected mock to not have been
awaited. Awaited 1 times.' — i.e. the test demonstrates the bug concretely.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter labels May 14, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #25444 (commit d557544 on main) with your authorship preserved via cherry-pick + rebase merge. Thanks for the clean fix + regression test!

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/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Free-response Discord channels spawn a new thread per message, contradicting documented inline-reply behavior

3 participants