From 524ab539947aa7a092d749921e0e93913cb683de Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 30 Jul 2026 15:00:07 -0700 Subject: [PATCH] fix(telegram): apply media read_timeout to all upload send paths, not just video send_video got the 60s read_timeout but send_voice/send_audio/send_photo/ send_document/send_media_group/send_animation upload through the same PTB request path and hit the same server-side processing wait before the response arrives. Same class, all sites: they all pass _MEDIA_SEND_READ_TIMEOUT now. Also drops an unused test helper. --- plugins/platforms/telegram/adapter.py | 6 ++++++ tests/tools/test_managed_tool_gateway.py | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py index 6639ba3d2e8cd..d3f48a90481e6 100644 --- a/plugins/platforms/telegram/adapter.py +++ b/plugins/platforms/telegram/adapter.py @@ -6821,6 +6821,7 @@ class TelegramAdapter(BasePlatformAdapter): "parse_mode": _cap_parse_mode, "reply_to_message_id": reply_to_id, "duration": _duration_secs, + "read_timeout": _MEDIA_SEND_READ_TIMEOUT, **voice_thread_kwargs, **self._notification_kwargs(metadata), }, @@ -6870,6 +6871,7 @@ class TelegramAdapter(BasePlatformAdapter): "caption": caption[:1024] if caption else None, "reply_to_message_id": reply_to_id, "duration": _duration_secs, + "read_timeout": _MEDIA_SEND_READ_TIMEOUT, **audio_thread_kwargs, **self._notification_kwargs(metadata), }, @@ -7008,6 +7010,7 @@ class TelegramAdapter(BasePlatformAdapter): "chat_id": normalize_telegram_chat_id(chat_id), "media": media, "reply_to_message_id": reply_to_id, + "read_timeout": _MEDIA_SEND_READ_TIMEOUT, **thread_kwargs, **self._notification_kwargs(metadata), }, @@ -7067,6 +7070,7 @@ class TelegramAdapter(BasePlatformAdapter): "photo": image_file, "caption": caption[:1024] if caption else None, "reply_to_message_id": reply_to_id, + "read_timeout": _MEDIA_SEND_READ_TIMEOUT, **thread_kwargs, **self._notification_kwargs(metadata), }, @@ -7164,6 +7168,7 @@ class TelegramAdapter(BasePlatformAdapter): "filename": display_name, "caption": caption[:1024] if caption else None, "reply_to_message_id": reply_to_id, + "read_timeout": _MEDIA_SEND_READ_TIMEOUT, **thread_kwargs, **self._notification_kwargs(metadata), }, @@ -7359,6 +7364,7 @@ class TelegramAdapter(BasePlatformAdapter): "animation": animation_url, "caption": caption[:1024] if caption else None, "reply_to_message_id": reply_to_id, + "read_timeout": _MEDIA_SEND_READ_TIMEOUT, **animation_thread_kwargs, **self._notification_kwargs(metadata), }, diff --git a/tests/tools/test_managed_tool_gateway.py b/tests/tools/test_managed_tool_gateway.py index 5a02ddff471e2..1c90bcb90f3b4 100644 --- a/tests/tools/test_managed_tool_gateway.py +++ b/tests/tools/test_managed_tool_gateway.py @@ -192,10 +192,6 @@ class TestManagedMediaUploader: BASE_URL = f"{GATEWAY}/api/bfl" UPLOAD_PATH = "/api/uploads/bfl" - @staticmethod - def _builder(vendor): - return f"https://{vendor}-gateway.example.com" - def _uploader(self, **kwargs): return managed_tool_gateway.build_managed_media_uploader( kwargs.pop("server_url", self.BASE_URL),