Skip to content

feat(discord): add per-user auto-thread exclusion via DISCORD_NO_THREAD_USERS - #22373

Open
VatsalyaB wants to merge 1 commit into
NousResearch:mainfrom
VatsalyaB:feat/discord-auto-thread-per-user-toggle
Open

feat(discord): add per-user auto-thread exclusion via DISCORD_NO_THREAD_USERS#22373
VatsalyaB wants to merge 1 commit into
NousResearch:mainfrom
VatsalyaB:feat/discord-auto-thread-per-user-toggle

Conversation

@VatsalyaB

Copy link
Copy Markdown

Summary

Adds the ability to exclude specific Discord users from auto-thread creation on @mention. This is useful for users who prefer the bot to respond directly in the channel instead of spawning a new thread every time.

Changes

New helper methods (gateway/platforms/discord.py)

  • _discord_auto_thread_enabled() — reads from config.extra.auto_thread first (config.yaml), then DISCORD_AUTO_THREAD env var, defaulting to True. Follows the same pattern as _discord_require_mention().
  • _discord_no_thread_users() — returns a set of Discord user IDs whose @mentions skip thread creation. Reads from config.extra.no_thread_users (YAML list) or DISCORD_NO_THREAD_USERS env var (comma-separated).

Modified auto-thread logic

The auto-thread decision block now checks three conditions before creating a thread (in precedence order):

  1. Per-user: if the caller's user ID is in no_thread_users → skip
  2. Per-channel: if the channel ID is in no_thread_channels → skip (unchanged)
  3. Global toggle: if auto_thread is false → skip (unchanged, now uses structured method)

Config bridging (gateway/config.py)

Both auto_thread and no_thread_users are bridged from config.yaml's platforms.discord.extra section into the platform extra dict and env vars, following existing patterns like free_response_channels and no_thread_channels.

Tests

6 new tests covering:

  • Per-user exclusion (test_no_thread_user_skips_auto_thread)
  • Non-excluded user still gets threads (test_non_no_thread_user_still_auto_threads)
  • CSV parsing of user IDs (test_no_thread_users_csv_parsing)
  • Channel precedence over user exclusion (test_no_thread_user_still_takes_channel_precedence)
  • Config bridging for no_thread_users (test_config_bridges_no_thread_users)
  • Config bridging for auto_thread (test_config_bridges_auto_thread)

All 41 tests pass (35 existing + 6 new).

Configuration

Via env var

DISCORD_NO_THREAD_USERS=331855188853915649,123456789012345678

Via config.yaml

platforms:
  discord:
    extra:
      no_thread_users:
        - "331855188853915649"
        - "123456789012345678"
      auto_thread: false  # also available as structured config

Related

  • Closes feature request from Curiosum Management Consulting Discord server

Add two new configuration options for Discord auto-threading:

- _discord_auto_thread_enabled(): reads from config.extra.auto_thread
  first (config.yaml), then DISCORD_AUTO_THREAD env var, defaulting to True.
  Uses the same pattern as _discord_require_mention().

- _discord_no_thread_users(): returns a set of Discord user IDs whose
  @mentions skip thread creation. Reads from config.extra.no_thread_users
  (config.yaml list) or DISCORD_NO_THREAD_USERS env var (comma-separated).

- Auto-thread decision logic checks per-user exclusion list before creating
  a thread, alongside existing per-channel (no_thread_channels) and global
  (auto_thread) controls. Precedence: no_thread_users > no_thread_channels
  > auto_thread global toggle.

- Config bridging: both auto_thread and no_thread_users bridged from
  config.yaml platforms section into platform extra (config.py) and env
  vars for adapter consumption.

- Tests: 6 new tests covering per-user exclusion, CSV parsing, channel
  precedence, config bridging for auto_thread and no_thread_users.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter labels May 9, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Discord routing control. The per-user exclusion is still needed: current main creates threads after checking only channel/free-response exclusions at plugins/platforms/discord/adapter.py:6221-6227.

Problems

  • The PR targets the pre-plugin paths. Discord was migrated from gateway/platforms/discord.py and the central config bridge in commit cc8e5ec2; the live adapter and YAML bridge are now plugins/platforms/discord/adapter.py:6221 and :8229.
  • The new setting also needs the established discord: config surface: defaults at hermes_cli/config.py:2425 and docs at website/docs/user-guide/messaging/discord.md:310 currently enumerate the related thread settings but not this one.
  • The PR description advertises a new non-secret .env setting. AGENTS.md:102-107 requires behavioral settings to be user-facing in config.yaml; the existing plugin YAML-to-env bridge can remain an internal implementation detail.

Suggested changes

  • Port the author-ID check into the live auto-thread branch, extend _apply_yaml_config() beside no_thread_channels, and add current-path tests plus config/docs coverage.

Automated hermes-sweeper review.

@teknium1 teknium1 added 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

@GottZ GottZ 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.

This was generated by AI during triage.

Summary

Two PRs address related Discord auto-thread exclusions but target different causes: #4611 adds per-channel exclusions, while #22373 adds the still-missing per-user exclusion and also changes mention handling. The channel-level behavior from #4611 is already implemented on main; the reusable part of #22373 must be ported to the current plugin architecture.

Related pull requests

  • #4611 [closed] related — (+51/-0) — close as already implemented on main: the closed PR added a per-channel auto-thread exclusion, but the contributor review identifies the equivalent discord.no_thread_channels implementation at gateway/config.py lines 652–657 and gateway/platforms/discord.py lines 3251–3256, introduced by commit f6d4b6a3198b35e2ee340c617b2f3193a9ab727b. It remains relevant as the superseded channel-level counterpart to #22373.
  • #22373 related — (+211/-5) — keep open with a salvage path: consistent with the MAINTAINER-BOT keep_open review, the diff contains a distinct per-user author-ID exclusion that current main still lacks, but it modifies obsolete gateway/ paths and mixes that feature with role-mention handling. Salvage the per-user check by porting it to plugins/platforms/discord/adapter.py:6221-6227, extending the YAML bridge near plugins/platforms/discord/adapter.py:8229, and adding current-path tests plus the config and documentation coverage identified in the review.

Suggested consolidation

Keep #22373 open with a salvage path limited to the per-user no-thread control: rebase or port that logic onto the live plugin paths, expose it through the established discord: YAML surface, add current-path tests and documentation, and split out the unrelated role-mention changes if they remain necessary. #4611 should remain closed because its channel-level behavior is already present on main via commit f6d4b6a3198b35e2ee340c617b2f3193a9ab727b; the two PRs are related controls, not duplicates.

Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 19 kB of PR diffs, 4 kB of issue/PR text, <1 kB of discussion (1 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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 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 type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants