Skip to content

reply_to_mode: 'off'ignored by Telegram DM topic reply fallback code #23994

@AlexGreenUK

Description

@AlexGreenUK

Bug Description

When platforms.telegram.reply_to_mode is set to "off" in config.yaml, the bot still quotes (replies to) the user's message on every response in Hermes-created DM topic lanes. The bot shows a quote bubble pointing to the user's triggering message despite explicit config requesting no quoting.

This was introduced in commit b323957 (fix(telegram): preserve DM topic routing via reply fallback). The new DM topic reply fallback code hardcodes should_thread = True when telegram_dm_topic_reply_fallback metadata is present, completely bypassing the TelegramAdapter._should_thread_reply() method that is the single point which checks _reply_to_mode.

Root Cause

gateway/platforms/telegram.py send() (line ~1492):

if metadata and metadata.get("telegram_dm_topic_reply_fallback"):
should_thread = reply_to_source is not None # ← ignores reply_to_mode
else:
should_thread = self._should_thread_reply(reply_to_source, i) # ← respects it

Additionally, _reply_to_message_id_for_send() and _thread_kwargs_for_send() unconditionally return the reply anchor for DM topic fallback sends — neither method accepts a reply_to_mode parameter, so all ~29 call sites propagate the ignore.

Expected Behavior

When reply_to_mode: "off" is set, no response message should include reply_to_message_id, regardless of whether the send uses DM topic routing, supergroup forum routing, or any other path.

Reproduction Steps

  1. Set platforms.telegram.reply_to_mode: 'off' in config.yaml
  2. Create a DM topic (e.g. General, RUBIX, etc.)
  3. Send any message to the bot in that topic
  4. Observe: the bot's reply shows a quote bubble pointing to your message

Affected Scenarios

reply_to_mode: 'off' in plain DM (no topics)

• Scenario: reply_to_mode: 'off' in plain DM (no topics)

• Works?: ✅ No quote

reply_to_mode: 'off' in DM topic lane

• Scenario: reply_to_mode: 'off' in DM topic lane

• Works?: ❌ Still quotes

reply_to_mode: 'first' in DM topic lane

• Scenario: reply_to_mode: 'first' in DM topic lane

• Works?: ✅ First reply only

reply_to_mode: 'all' in DM topic lane

• Scenario: reply_to_mode: 'all' in DM topic lane

• Works?: ✅ Every reply

Inline-approval buttons in DM topic lane

• Scenario: Inline-approval buttons in DM topic lane

• Works?: ❌ Still quote

Media sends in DM topic lane

• Scenario: Media sends in DM topic lane

• Works?: ❌ Still quote

Environment

  • Hermes Agent 0.13.0
  • Commit b323957 (fix(telegram): preserve DM topic routing via reply fallback)
  • platforms.telegram.reply_to_mode: 'off'
  • Hermes-created DM topics (via extra.dm_topics)

Proposed Fix

  1. Add reply_to_mode: Optional[str] = None kwarg to _reply_to_message_id_for_send() and _thread_kwargs_for_send()
  2. In _reply_to_message_id_for_send: return None when reply_to_mode == "off" and path is DM fallback
  3. In _thread_kwargs_for_send: return {"message_thread_id": ...} without reply anchor when reply_to_mode == "off"
  4. In send(): change to should_thread = reply_to_source is not None and self._reply_to_mode != "off"
  5. Thread reply_to_mode=self._reply_to_mode at all call sites (~29 total)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptersweeper:implemented-on-mainSweeper: behavior already present on current maintype/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