Skip to content

feat(discord): semantic thread titles for auto-created threads - #56792

Closed
rungmc357 wants to merge 1 commit into
NousResearch:mainfrom
rungmc357:discord-semantic-thread-titles
Closed

feat(discord): semantic thread titles for auto-created threads#56792
rungmc357 wants to merge 1 commit into
NousResearch:mainfrom
rungmc357:discord-semantic-thread-titles

Conversation

@rungmc357

Copy link
Copy Markdown
Contributor

Summary

When Hermes auto-creates a Discord thread from a mention, the thread gets a
fast placeholder name derived from the raw message content (first 80 chars
with mention syntax stripped). This is the same pattern Telegram already has
for forum topics — but Discord threads keep that placeholder forever.

This PR adds the Discord equivalent of the existing Telegram
_rename_telegram_topic_for_session_title flow:

  1. _auto_create_thread tags the created thread with
    _hermes_auto_thread_initial_name (the placeholder name)
  2. SessionSource gains auto_thread_created and
    auto_thread_initial_name fields so the gateway can distinguish
    Hermes-created threads from pre-existing or human-renamed ones
  3. After the first agent turn, when the auto-title generator produces a
    session title, the gateway schedules a best-effort
    adapter.rename_thread() that renames only threads whose current name
    still matches the original placeholder — so human-renamed threads are
    never overwritten
  4. rename_thread on the Discord adapter is guarded with
    only_if_current_name to prevent clobbering

This mirrors the Telegram topic rename path (_is_telegram_topic_lane
_schedule_telegram_topic_title_rename
_rename_telegram_topic_for_session_title) and reuses the same
title_callback hook in maybe_auto_title.

Changes

  • gateway/session.py: Add auto_thread_created /
    auto_thread_initial_name to SessionSource (dataclass + serialization)
  • gateway/platforms/base.py: Pass new fields through _make_session_source
  • plugins/platforms/discord/adapter.py: Extract _derive_auto_thread_name,
    tag created threads with initial name, add rename_thread method with
    only_if_current_name guard
  • gateway/run.py: Add _is_discord_auto_thread_lane,
    _sanitize_discord_thread_title,
    _rename_discord_auto_thread_for_session_title,
    _schedule_discord_semantic_thread_rename; wire the title callback for
    Discord auto-thread lanes
  • tests/gateway/test_discord_slash_commands.py: Tests for auto-thread
    config bridge
  • tests/gateway/test_fast_command.py: Tests for fast-command dispatch on
    auto-thread lanes

Test plan

python -m pytest tests/gateway/test_discord_slash_commands.py \
  tests/gateway/test_fast_command.py -o 'addopts=' -q

All 43 tests pass.

@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter P3 Low — cosmetic, nice to have labels Jul 2, 2026
@teknium1

teknium1 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Merged via #60187 - your commit was cherry-picked onto current main with your authorship preserved in git log, plus a small follow-up making the title sanitizers UTF-16-safe. Your implementation was chosen from six competing PRs for having the right scoping guard (auto_thread_created + only_if_current_name) at the right size. Thanks!

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.

3 participants