Skip to content

[Bug]: Telegram DM auto-topic-rename and tool-call routing broken by _recover_telegram_topic_thread_id() #30411

@KixPanganiban

Description

@KixPanganiban

Bug Description

Root-DM messages to the Hermes Telegram gateway no longer create new topics. Every reply from the root DM gets pinned back to whatever topic you were most recently talking in. Auto-topic-renaming also silently breaks when disable_topic_auto_rename is not explicitly set.

Previously, sending a new message from the root Telegram DM created a new topic, got auto-renamed to match the conversation after a turn, and had tool-call progress routed to that same topic. Now new root messages silently re-use the last active topic, breaking session isolation — you end up with two separate conversations tangled in one topic, or tool-call output showing up in a different topic than where you replied.

Steps to Reproduce

  1. Run Hermes gateway with Telegram enabled, telegram.extra.disable_topic_auto_rename unset (defaults to false).
  2. Send a message from the Telegram root DM — a new topic is created (expected).
  3. Reply in that topic — it gets auto-renamed (may or may not work depending on flag state).
  4. Send a new message from the root DM again — instead of creating a fresh topic, the response appears in the topic from step 2.

Expected Behavior

A new root-DM message creates a new topic. After one turn in the new topic, the topic gets auto-renamed to match the conversation. Tool-call progress routes to whichever topic the conversation is in.

Actual Behavior

Root-DM messages no longer create new topics. Instead, _recover_telegram_topic_thread_id() pins them to the most recent topic, which breaks the expected root-DM → new-topic flow and makes auto-rename/tool-call routing behave incorrectly.

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

Telegram

Debug Report

Unable to run `hermes debug share` at time of filing. Root cause is identified below with file paths and code references.

Operating System

CachyOS (Arch-based)

Python Version

3.11.15

Hermes Version

v2026.5.16-702-ga8cbcf1c8

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

The bug is in gateway/run.py. Commit ede47a54b added _recover_telegram_topic_thread_id() which routes incoming root-DM messages to the user's most recent topic instead of creating a new one. The revert is straightforward — git revert ede47a54b.

Proposed Fix (optional)

Revert commit ede47a54b. If the pinning behavior (routing root-DM replies to the current topic) is desired, make it opt-in via a config flag like telegram.extra.pin_root_dm_replies: true.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions