From 6f817e1447499cf51d8c966b3f3a600ba3412f85 Mon Sep 17 00:00:00 2001 From: helix4u <4317663+helix4u@users.noreply.github.com> Date: Sat, 16 May 2026 16:23:35 -0600 Subject: [PATCH] fix(telegram): restore DM topic typing indicator --- gateway/platforms/telegram.py | 8 -------- tests/gateway/test_telegram_thread_fallback.py | 17 +++++++++-------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/gateway/platforms/telegram.py b/gateway/platforms/telegram.py index 4c56937e5cb..50813c25dc6 100644 --- a/gateway/platforms/telegram.py +++ b/gateway/platforms/telegram.py @@ -3504,14 +3504,6 @@ class TelegramAdapter(BasePlatformAdapter): if self._bot: try: _typing_thread = self._metadata_thread_id(metadata) - # Skip the Bot API call entirely for Hermes-created DM topic - # lanes: send_chat_action only accepts message_thread_id, which - # Telegram's Bot API 10.0 rejects for these lanes. The send - # path uses the reply-anchor fallback instead, but typing has - # no equivalent — skipping avoids noisy "thread not found" - # debug logs on every typing tick. - if metadata and metadata.get("telegram_dm_topic_reply_fallback"): - return message_thread_id = self._message_thread_id_for_typing(_typing_thread) # No retry-without-thread fallback here: _message_thread_id_for_typing # already maps the forum General topic to None, so any non-None value diff --git a/tests/gateway/test_telegram_thread_fallback.py b/tests/gateway/test_telegram_thread_fallback.py index e31753cc2b7..f310d017946 100644 --- a/tests/gateway/test_telegram_thread_fallback.py +++ b/tests/gateway/test_telegram_thread_fallback.py @@ -236,14 +236,13 @@ async def test_send_typing_does_not_fall_back_to_root_for_dm_topic(): @pytest.mark.asyncio -async def test_send_typing_skips_api_call_for_dm_topic_reply_fallback(): - """Hermes-created DM topic lanes have no working Bot API typing route. +async def test_send_typing_attempts_api_call_for_dm_topic_reply_fallback(): + """Hermes-created DM topic lanes should still attempt scoped typing. - ``send_chat_action`` only accepts ``message_thread_id``, which Telegram's - Bot API 10.0 rejects for these lanes — the call would silently fail and - log a "thread not found" warning every typing tick (every 2s). Skipping - the call entirely keeps logs clean while preserving the user-visible - behavior (no typing indicator either way for these lanes). + Some private DM topic lanes route message sends through reply-anchor + fallback, but live Telegram testing shows sendChatAction accepts the lane's + message_thread_id. If Telegram rejects a stale or invalid thread later, + send_typing already swallows that failure as non-fatal. """ adapter = _make_adapter() call_log = [] @@ -262,7 +261,9 @@ async def test_send_typing_skips_api_call_for_dm_topic_reply_fallback(): }, ) - assert call_log == [] + assert call_log == [ + {"chat_id": 12345, "action": "typing", "message_thread_id": 20197}, + ] @pytest.mark.asyncio