Skip to content

The agent that grows with you

fix(telegram): catch NetworkError, not TelegramError, after a kept-prompt edit fails

Tekniumce0602e8a97b
diff --git a/plugins/platforms/telegram/telegram_resolved_prompt.py b/plugins/platforms/telegram/telegram_resolved_prompt.py
index f8098ea9590..fa73ecd4206 100644
--- a/plugins/platforms/telegram/telegram_resolved_prompt.py
+++ b/plugins/platforms/telegram/telegram_resolved_prompt.py
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
async def edit_keeping_prompt(adapter: Any, query: Any, decision: str) -> None:
"""Append *decision* to the prompt and drop its buttons; the adapter's decision-only edit runs when
the prompt has no readable body or the appended line pushes it past Telegram's length cap."""
- from telegram.error import BadRequest, TelegramError
+ from telegram.error import BadRequest, NetworkError
body = getattr(query.message, "text_html", None) if query.message else None
if isinstance(body, str) and body:
@@ -28,7 +28,7 @@ async def edit_keeping_prompt(adapter: Any, query: Any, decision: str) -> None:
return
except BadRequest: # too long / unparsable: the decision-only edit below still clears the buttons
pass
- except TelegramError as exc: # network/timeout: the edit may have landed, so keep the prompt as is
+ except NetworkError as exc: # network/timeout: the edit may have landed, so keep the prompt as is
logger.debug("Telegram resolved-prompt edit failed: %s", exc)
return
await adapter._edit_md_quiet(query, decision)