Skip to content

feat: enhanced Discord thread management#215

Open
howie wants to merge 7 commits intoopenabdev:mainfrom
howie:claude/modest-kowalevski
Open

feat: enhanced Discord thread management#215
howie wants to merge 7 commits intoopenabdev:mainfrom
howie:claude/modest-kowalevski

Conversation

@howie
Copy link
Copy Markdown

@howie howie commented Apr 11, 2026

Summary

Inspired by OpenClaw Discord Workflow, adds advanced thread management features to improve the Discord experience for multi-user environments.

Closes #188

New Features

  • Configurable auto-archive duration — Set auto_archive_duration to 60 (1h), 1440 (1d), 4320 (3d), or 10080 (1w). Previously hardcoded to 1 day.
  • Per-channel configuration — Each Discord channel can override global defaults via [discord.channels."<ID>"] sections in config.
  • Direct mode (require_mention = false) — Any message in the channel triggers a thread, no @mention needed. Ideal for dedicated bot channels.
  • Ignore other mentions (ignore_other_mentions = true) — Skip messages that mention other bots/users but not this bot. Prevents false triggers in multi-bot environments.
  • LLM-generated thread names (thread_name_mode = "generated") — After the main prompt completes, a background task asks the agent for a short title and renames the thread. Falls back to truncated name on failure (10s timeout).

Config Example

[discord]
auto_archive_duration = 1440
require_mention = true
ignore_other_mentions = false
thread_name_mode = "truncate"

[discord.channels."111111"]
require_mention = false
thread_name_mode = "generated"
auto_archive_duration = 60

Files Changed

  • src/config.rsChannelConfig struct, new fields on DiscordConfig, validation
  • src/discord.rs — Per-channel config resolution, direct mode, ignore logic, background thread naming
  • src/main.rs — Pass new config fields to Handler
  • config.toml.example — Document all new options
  • charts/openab/values.yaml — Helm values for new settings
  • charts/openab/templates/configmap.yaml — Template per-channel config

Known Limitations

  • Thread naming uses the same ACP session as the user conversation, which adds a naming turn to the session history. A dedicated lightweight API call would be cleaner but requires additional dependencies.
  • with_connection holds a global write lock during the naming request. Under high concurrent load with thread_name_mode = "generated", this may cause brief stalls for other threads.

Test plan

  • Deploy with default config — verify no behavioral change (backward compat)
  • Set auto_archive_duration = 60 — verify threads archive after 1 hour
  • Set require_mention = false on a channel — verify any message creates a thread
  • Set ignore_other_mentions = true — verify messages mentioning other bots are skipped
  • Set thread_name_mode = "generated" — verify thread gets renamed after first response
  • Test per-channel overrides with different settings per channel
  • Test invalid config values (e.g., auto_archive_duration = 999) — verify startup fails with clear error
  • helm template with new values — verify configmap output is correct

🤖 Generated with Claude Code

howie and others added 7 commits April 11, 2026 20:29
Adds `auto_archive_duration` to `DiscordConfig` with a default of 1440 (OneDay).
Validates at config load time that the value is one of 60/1440/4320/10080.
Passes the configured value through `Handler` to `get_or_create_thread` and
converts it to the appropriate `AutoArchiveDuration` enum variant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add per-channel configuration overrides via `[discord.channels."ID"]`
TOML sections. Each channel can independently override:
- require_mention: when false, any message triggers the bot (direct mode)
- ignore_other_mentions: skip messages mentioning other users/bots
- auto_archive_duration: per-channel thread archive duration
- thread_name_mode: per-channel thread naming strategy

New global defaults on DiscordConfig: require_mention (true),
ignore_other_mentions (false), thread_name_mode ("truncate").
Channel overrides fall back to global defaults when not set.

Validation of auto_archive_duration also applies to channel overrides.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use parent_channel_id (not thread ID) for per-channel config resolution
- Remove unused effective_* methods from DiscordConfig (logic is inline in Handler)
- Cache channel_override lookup to avoid repeated HashMap access

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When thread_name_mode is set to "generated" (global or per-channel),
sends a short naming prompt to the ACP session after thread creation
and renames the thread via Discord API before the main response.
Falls back to the truncated name on any failure (timeout, error).

Includes config validation for thread_name_mode values at load time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Run LLM thread naming after main prompt completes in a tokio::spawn task
  instead of blocking before stream_prompt. This avoids:
  - Holding the pool write-lock during the naming request
  - Delaying the user's response while a name is generated
  - The naming prompt appearing before the user's real message in session history
- Add "Do not use any tools" to naming prompt to prevent tool-use overhead
- Strip quotes and markdown formatting from generated names

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… options

- config.toml.example: add require_mention, ignore_other_mentions,
  thread_name_mode, and per-channel override examples
- values.yaml: add discord.autoArchiveDuration, requireMention,
  ignoreOtherMentions, threadNameMode, and channels map
- configmap.yaml: template per-channel config with range loop

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thepagent
Copy link
Copy Markdown
Collaborator

This is a large feature with per-channel config, direct mode, and background thread naming. Could you please create a Discord discussion thread and add the link to this PR description? This helps with design review and community feedback for bigger features. Thanks! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: enhanced Discord thread management (auto-thread, LLM naming, configurable archive)

2 participants