Skip to content

fix(telegram): respect reply_to_mode for DM topic reply fallback#28477

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-6063e704
May 19, 2026
Merged

fix(telegram): respect reply_to_mode for DM topic reply fallback#28477
teknium1 merged 1 commit into
mainfrom
hermes/hermes-6063e704

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #24004 (@liuhao1024).

Summary

reply_to_mode: 'off' was silently ignored for Telegram messages routed through the Hermes-created DM topic fallback path. The DM-topic fallback in send() hardcoded should_thread = reply_to_source is not None, completely bypassing _should_thread_reply() (the single method that checks _reply_to_mode). Also _reply_to_message_id_for_send() and _thread_kwargs_for_send() unconditionally returned the reply anchor.

Changes

  • gateway/platforms/telegram.py: thread reply_to_mode through _reply_to_message_id_for_send() and _thread_kwargs_for_send(); send() now checks self._reply_to_mode != 'off' before setting should_thread.
  • tests/gateway/test_telegram_reply_mode.py: coverage.

Validation

  • scripts/run_tests.sh tests/gateway/test_telegram_reply_mode.py -q → 40/40 passing.
  • scripts/run_tests.sh tests/gateway/test_telegram_thread_fallback.py -q → 34/34 passing (no regression).

Also supersedes #24060 (@KenjiChao) which fixed the same bug — closed with credit.

Authorship preserved via cherry-pick.

The DM topic reply fallback code in send() hardcoded should_thread=True
when telegram_dm_topic_reply_fallback metadata was present, bypassing
_should_thread_reply() and ignoring reply_to_mode config. This caused
quote bubbles on every response even with reply_to_mode: 'off'.

Fix:
- Add reply_to_mode param to _reply_to_message_id_for_send() and
  _thread_kwargs_for_send() classmethods
- In send(), check self._reply_to_mode != 'off' for DM topic fallback
- Suppress reply anchor and reply_to_message_id when mode is 'off'
  while preserving message_thread_id for correct topic routing
- Thread reply_to_mode through all 29 call sites

Regression coverage: 10 new tests in test_telegram_reply_mode.py
covering classmethod behavior, send() integration, and backward
compatibility.

Fixes reply_to_mode: 'off' ignored by Telegram DM topic reply fallback code #23994
@teknium1 teknium1 merged commit 21a15b6 into main May 19, 2026
@teknium1 teknium1 deleted the hermes/hermes-6063e704 branch May 19, 2026 04:52
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-6063e704 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8876 on HEAD, 8876 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4647 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants