Skip to content

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

Open
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-56792
Open

feat(discord): semantic thread titles for auto-created threads#646
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-56792

Conversation

@hashbender

Copy link
Copy Markdown
Owner

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.


Mirror-of: NousResearch#56792
NousResearch#56792

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.

1 participant