feat(discord): sync thread names from session titles - #57679
Closed
yshen92 wants to merge 1 commit into
Closed
Conversation
Add Discord thread title sync from Hermes-generated session titles behind config (discord.auto_rename_threads). Disabled by default; when enabled, session title callbacks and optional /title sync rename visible Discord thread names via DiscordAdapter.rename_thread. - Gateway: _is_discord_thread_lane, _sanitize_discord_thread_title, _schedule_discord_thread_title_rename wired through existing maybe_auto_title title_callback seam - Adapter: DiscordAdapter.rename_thread with get_channel/fetch_channel fallback, permission/archive error handling, and no raises to response delivery - Config: discord.auto_rename_threads.enabled/mode/sync_title_command/max_length defaults, no new env var - /title sync gated by sync_title_command + enabled + mode=session_title + Discord thread source; scheduler called directly from the async handler - Tests: 22 new test cases; 122-test targeted suite green across affected files and regressions - Docs: discord.md and config example document command-sync coupling, 100-character clamp, and Discord rate-limit behavior Refs: NousResearch#18430, NousResearch#33862
yshen92
marked this pull request as ready for review
July 3, 2026 14:42
Contributor
|
Fixed via #60187 (salvage of #56792 by @rungmc357). We went with the default-on, guard-based approach (matching how Telegram topic rename shipped) over a config gate. Thanks for the thorough config plumbing and tests! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #18430.
Hermes-created Discord threads already get generated session titles, but the visible Discord thread name stays as the original user-message snippet. That makes Discord's native thread list hard to scan because threads keep cryptic or truncated names even after Hermes has a better session title.
This PR syncs Hermes-generated session titles to visible Discord thread names, behind an opt-in config gate. It reuses the existing session-title flow and the existing
maybe_auto_title(..., title_callback=...)seam. It does not add a new model tool, model schema, or environment variable.Mapping to #18430
discord.auto_rename_threads.enabled, defaultfalsemaybe_auto_titletitle_callbackseam;agent/title_generator.pyuntouched/titlerenames only behind a separate optionsync_title_command, defaultfalse(requiresenabled: trueandmode: session_title)Limitations
This PR renames the thread whenever a session title is generated while the feature is enabled; it does not detect that a user manually renamed the thread in the meantime. This is a deliberate scope cut to keep the diff minimal and avoid per-thread initial-name state. If maintainers want the guard in this PR, I'm happy to add an initial-name check as a follow-up commit; #35420's
thread_initial_nameapproach shows one viable shape.Relationship to existing Discord thread-title PRs
Several PRs target #18430 or adjacent thread-naming behavior. This PR is the narrow, strictly opt-in implementation of the issue's proposed solution.
summarymode, new environment variables, bidirectional Discord-to-session title sync, an initial-name guard, and changes to the platform base interface and title-generator internals. This PR is strictly opt-in per the issue's guardrails, keeps all config inconfig.yamlwith no env vars, and does not touchagent/title_generator.py, session internals, or the platform base interface. Smaller reviewable surface: one commit on the existing callback seam./titleto Discord thread names, but polls the session DB (up to 15s latency) against an older gateway layout. This PR is event-driven via the existing callback and targets the current plugin-based Discord adapter layout.So the claim is not "nobody has proposed this." The claim is "this is the current, tested, strictly opt-in implementation matching the issue's proposed guardrails, with the smallest blast radius of the open attempts."
Related Issue
Fixes #18430
Related: #35420, #15757, #29983, #26477, #30559, #13915, #3009, #33862
Type of Change
Changes Made
gateway/run.pyplugins/platforms/discord/adapter.pyDiscordAdapter.rename_thread(thread_id, name).get_channelfirst andfetch_channelfallback.gateway/slash_commands.py/title Nameso manual session titles can also sync the visible Discord thread name when explicitly enabled./titlebehavior unchanged.gateway/config.py,hermes_cli/config.py,cli-config.yaml.examplediscord.auto_rename_threadsconfig with disabled defaults:website/docs/user-guide/messaging/discord.md/titlecoupling, 100-character Discord name cap, and rate-limit considerations./titlecoverage (including a test that exercises the real/title→ scheduler → adapter path, RED on pre-fix code), config-default coverage, adversarial cases (invalid thread IDs, missing adapter/client, cache-miss fetch fallback), and regression checks for existing Discord/Telegram behavior.How to Test
Automated checks run locally:
Result:
Syntax check:
Result:
Manual rollout check performed on a Discord gateway instance after enabling:
Verified behavior:
/title Manual English Titleupdated both the stored Hermes session title and the visible Discord thread name.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passNote: I ran the targeted gateway/config regression suite above, not the full
pytest tests/ -qsuite.Documentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
No screenshots attached to keep the PR focused on code and tests.
Relevant verification summary:
Privacy/data guardrails
agent/title_generator.pypath..envvariable added. Behavioral config lives inconfig.yaml.