fix(telegram): respect reply_to_mode for DM topic reply fallback#28477
Merged
Conversation
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
Contributor
🔎 Lint report:
|
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.
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 insend()hardcodedshould_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: threadreply_to_modethrough_reply_to_message_id_for_send()and_thread_kwargs_for_send();send()now checksself._reply_to_mode != 'off'before settingshould_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.