feat(telegram): sync auto-generated session titles to forum topic names - #16408
Closed
cola-runner wants to merge 1 commit into
Closed
feat(telegram): sync auto-generated session titles to forum topic names#16408cola-runner wants to merge 1 commit into
cola-runner wants to merge 1 commit into
Conversation
Collaborator
Hermes auto-generates a session title via ``agent/title_generator.py`` and saves it to SQLite, but never propagates the change to the corresponding Telegram forum topic. Users with many concurrent topics can't tell them apart in the Telegram sidebar — every topic stays named "New Session" forever while ``/history`` shows the real title. This wires the two systems together with three small layers: - ``BasePlatformAdapter.update_topic_title`` — new optional async hook, default no-op. Platforms with per-thread titles override it. - ``TelegramAdapter.update_topic_title`` — calls ``editForumTopic`` with the new name (truncated to Telegram's 128-char cap), skips the General topic, swallows API errors at DEBUG, and keeps the local ``_dm_topics`` cache aligned so ``/resume``-style lookups by name still find the renamed topic. - ``title_generator`` — adds an ``on_title_set`` callback that fires *after* the new title is persisted to SQLite. Callback exceptions are swallowed so a flaky platform call can't crash the worker thread. - ``GatewayRunner._sync_topic_title_to_platform`` and ``_make_topic_title_sync_callback`` bridge the auto-title daemon thread back to the gateway event loop via ``run_coroutine_threadsafe``. Wired into both auto-title and the ``/title`` command so manual renames sync immediately. Closes NousResearch#16255.
cola-runner
force-pushed
the
codex/fix-16255-telegram-topic-title-sync
branch
from
April 29, 2026 10:51
829b2f1 to
b1377e3
Compare
19 tasks
2 tasks
19 tasks
Contributor
|
Thanks for the Telegram topic-title synchronization work. The member duplicate note linking #9921 was correct: current Automated hermes-sweeper review evidence:
|
This was referenced Jul 27, 2026
Open
19 tasks
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.
Summary
Closes #16255. Connects two systems that were developed independently:
agent/title_generator.pygenerates a session title and saves it to SQLite.gateway/platforms/telegram.pycreates / tracks forum topics but never updates their names after creation.After this PR, when a session title is auto-generated or set manually via
/title, the corresponding Telegram forum topic name is updated viaeditForumTopicso the topic list and/historystay in sync.Architecture
Three small layers, no behaviour change for non-Telegram platforms:
BasePlatformAdapter.update_topic_title— new async hook, default no-op. Platforms with per-thread titles override it. Errors must be swallowed by the implementation — title sync is best-effort UX.TelegramAdapter.update_topic_title— callseditForumTopicwith the new name, truncates to Telegram's 128-char limit, skips the implicit "General" topic (its name is owned by the chat, not the bot), DEBUG-logs Bot API failures, and re-aligns the local_dm_topicscache so/resumelookups by name still find the renamed topic.title_generator— adds anon_title_setcallback that fires after the new title is persisted to SQLite. Callback exceptions are swallowed so a flaky platform call can't crash the daemon worker.Sync→async bridge
maybe_auto_titleruns in a daemonthreading.Thread, so we hop back to the gateway loop viaasyncio.run_coroutine_threadsafe:GatewayRunner._make_topic_title_sync_callbackbuilds the callback (skipping early when the source has no thread_id — most non-forum chats).GatewayRunner._sync_topic_title_to_platformlooks up the right adapter and awaits itsupdate_topic_title.The
/titlecommand reuses the same_sync_topic_title_to_platformso manual renames push to the platform immediately.Files
gateway/platforms/base.py— newupdate_topic_titleno-op defaultgateway/platforms/telegram.py— Telegram override + cache realignmentagent/title_generator.py—on_title_setcallback throughmaybe_auto_title/auto_title_sessiongateway/run.py— gateway helpers + wires both auto-title and/titletests/agent/test_title_generator.py— 5 new tests for the callbacktests/gateway/test_telegram_topic_title.py— 13 new tests for the overrideTest plan
pytest tests/agent/test_title_generator.py tests/gateway/test_telegram_topic_title.py tests/gateway/test_telegram_format.py— 125 passed locally