Skip to content

feat(discord): generate auto-thread titles - #3009

Closed
chhoumann wants to merge 5 commits into
NousResearch:mainfrom
chhoumann:codex/discord-thread-titles
Closed

feat(discord): generate auto-thread titles#3009
chhoumann wants to merge 5 commits into
NousResearch:mainfrom
chhoumann:codex/discord-thread-titles

Conversation

@chhoumann

Copy link
Copy Markdown

What does this PR do?

Adds an opt-in Discord setting to generate auto-thread titles with Hermes' auxiliary title generator before creating the thread, instead of deriving the thread name directly from the incoming message text.

This adds:

  • discord.generate_thread_titles in config.yaml
  • DISCORD_GENERATE_THREAD_TITLES as the env override
  • pre-create title generation in the Discord auto-thread flow
  • fallback to the existing truncated-message thread name if generation fails or returns empty

Implementation-wise, this also extracts the generic title-generation primitive into a neutral module so the Discord gateway does not depend on the session-title orchestration module.

Related Issue

N/A

I did not find an existing issue/discussion for this feature.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added discord.generate_thread_titles to hermes_cli/config.py and bumped _config_version
  • Bridged discord.generate_thread_titles to DISCORD_GENERATE_THREAD_TITLES in gateway/config.py
  • Updated Discord auto-thread creation in gateway/platforms/discord.py to generate a title before create_thread(...)
  • Added generic title-generation helpers in agent/title_generation.py
  • Kept agent/title_generator.py focused on session-title orchestration by delegating to the shared helper
  • Added shared env parsing helpers in utils.py and reused them in the Discord adapter
  • Updated docs in website/docs/user-guide/messaging/discord.md and website/docs/reference/environment-variables.md
  • Updated cli-config.yaml.example
  • Added/updated tests in:
    • tests/agent/test_title_generation.py
    • tests/agent/test_title_generator.py
    • tests/gateway/test_discord_slash_commands.py
    • tests/hermes_cli/test_config.py
    • tests/test_env_utils.py
    • tests/tools/test_local_env_blocklist.py

How to Test

  1. Enable Discord auto-threading and thread-title generation via config or env:
    • discord.auto_thread: true
    • discord.generate_thread_titles: true
  2. Mention Hermes in a normal Discord channel (not a DM, not an existing thread)
  3. Confirm Hermes creates a new thread whose name is model-generated rather than the raw message text
  4. Disable discord.generate_thread_titles and confirm auto-threads fall back to the existing truncated-message title behavior
  5. Optionally force title generation failure/unavailability and confirm thread creation still succeeds with the fallback name

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Focused tests for touched areas:

  • 111 passed

Full suite in the repo's intended local dev environment (uv venv venv --python 3.11, uv pip install -e ".[all,dev]", python -m pytest tests/ -q):

  • 6178 passed, 164 skipped, 4 failed

The remaining failures appear unrelated to this PR:

  • tests/agent/test_prompt_builder.py::TestBuildContextFilesPrompt::test_claude_md_uppercase_takes_priority
  • tests/test_streaming.py::TestStreamingFallback::test_any_stream_error_falls_back
  • tests/test_streaming.py::TestStreamingFallback::test_fallback_error_propagates
  • tests/tools/test_transcription.py::TestGetProvider::test_explicit_openai_no_key_returns_none

I also checked main in the same environment:

  • the prompt-builder and two streaming failures also fail on main
  • the transcription failure is order-dependent and appears to be caused by test env leakage unrelated to this PR

@chhoumann

Copy link
Copy Markdown
Author

In the future, it'd be super cool to learn the user's preference for the titles. I don't think memory or e.g. USER.md is necessarily the ideal place to learn this kind of feature, as you'd want to reliably extract it each time quite quickly.

@chhoumann

Copy link
Copy Markdown
Author

Also, I realize using the default model may be overkill for generating a title. E.g. I'm using GPT 5.4, while a Mini or Haiku model would suffice.

Ideally, the system would support configuring specific models for specific tasks, which would be useful system-wide.

@chhoumann
chhoumann force-pushed the codex/discord-thread-titles branch 3 times, most recently from 1be9cc4 to ac288ef Compare March 31, 2026 14:24
@chhoumann
chhoumann force-pushed the codex/discord-thread-titles branch from ac288ef to c8995cd Compare April 3, 2026 14:42
…titles

# Conflicts:
#	website/docs/user-guide/messaging/discord.md
…titles

# Conflicts:
#	gateway/platforms/discord.py
#	website/docs/reference/environment-variables.md
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