hermes - 💡(How to fix) Fix Telegram tool-progress edits permanently fall back to separate messages after transient edit_message network error [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Traceback (most recent call last): File "gateway/platforms/telegram.py", line 1120, in edit_message await self._bot.edit_message_text(...) ... telegram.error.NetworkError: httpx.ConnectError:

Root Cause

Because Telegram edit_message returns SendResult(success=False, error="httpx.ConnectError: ..."), this one transient error disables editing for the remainder of the run.

Fix Action

Fixed

Code Example

Traceback (most recent call last):
  File "gateway/platforms/telegram.py", line 1120, in edit_message
    await self._bot.edit_message_text(...)
...
telegram.error.NetworkError: httpx.ConnectError:

---

result = await adapter.edit_message(...)
if not result.success:
    _err = (getattr(result, "error", "") or "").lower()
    if "flood" in _err or "retry after" in _err:
        logger.info("Progress edits disabled due to flood control")
    can_edit = False
    await adapter.send(chat_id=source.chat_id, content=msg, metadata=_progress_metadata)

---

def should_disable_progress_edits_after_failure(result) -> bool:
    error = str(getattr(result, "error", "") or "").lower()
    if getattr(result, "retryable", False):
        return False
    if any(p in error for p in ("flood", "retry after", "message to edit not found", "message can't be edited", "message cannot be edited", "message_id_invalid", "not enough rights")):
        return True
    if BasePlatformAdapter._is_retryable_error(error):
        return False
    if any(p in error for p in ("timed out", "readtimeout", "writetimeout", "server disconnected", "temporarily unavailable", "temporary failure")):
        return False
    return True
RAW_BUFFERClick to expand / collapse

Bug Description

On Telegram, gateway tool progress is normally accumulated into one message and updated via edit_message. If a single transient edit_message_text network failure occurs (for example telegram.error.NetworkError: httpx.ConnectError), the gateway currently treats that edit failure as a permanent edit-capability failure, sets can_edit = False, and then sends each later tool progress line as a separate message.

This makes long-running runs suddenly switch from "append/update one progress message" to many separate bubbles after a temporary Telegram network hiccup.

Steps to Reproduce

  1. Start a long Telegram-triggered run with display.tool_progress: all so tool progress updates are visible.
  2. Let the run execute several tool calls while the progress message is being edited.
  3. During an edit operation, have Telegram edit_message_text fail once with a transient network error such as httpx.ConnectError.
  4. Continue the run with more tool calls.

Expected Behavior

Transient edit failures should not permanently disable progress-message editing. The gateway should keep accumulating progress lines and retry editing on the next update/final flush, so the run continues updating the same progress message.

Permanent edit failures such as flood control / long RetryAfter, missing message, or unsupported edit should still fall back to send-only behavior.

Actual Behavior

After any failed adapter.edit_message(...) result in gateway/run.py, the progress sender sets can_edit = False and sends a fallback line. All later progress updates become new messages instead of edits.

Observed log excerpt:

Traceback (most recent call last):
  File "gateway/platforms/telegram.py", line 1120, in edit_message
    await self._bot.edit_message_text(...)
...
telegram.error.NetworkError: httpx.ConnectError:

After this, later tool progress messages were delivered as separate bubbles.

Suspected Cause

In gateway/run.py inside send_progress_messages(), the failure path for editing does not distinguish transient network errors from permanent edit failures:

result = await adapter.edit_message(...)
if not result.success:
    _err = (getattr(result, "error", "") or "").lower()
    if "flood" in _err or "retry after" in _err:
        logger.info("Progress edits disabled due to flood control")
    can_edit = False
    await adapter.send(chat_id=source.chat_id, content=msg, metadata=_progress_metadata)

Because Telegram edit_message returns SendResult(success=False, error="httpx.ConnectError: ..."), this one transient error disables editing for the remainder of the run.

Proposed Fix

Only disable progress edits for permanent edit failures (flood control / long RetryAfter, message not found, message cannot be edited, permissions, etc.). For transient network errors (ConnectError, ConnectionError, timeouts, server disconnected, temporary failures), keep can_edit = True and skip sending a fallback progress line; the next successful edit can catch the accumulated message up.

A small helper like this would preserve current fallback behavior for permanent failures while avoiding message splitting after a temporary Telegram outage:

def should_disable_progress_edits_after_failure(result) -> bool:
    error = str(getattr(result, "error", "") or "").lower()
    if getattr(result, "retryable", False):
        return False
    if any(p in error for p in ("flood", "retry after", "message to edit not found", "message can't be edited", "message cannot be edited", "message_id_invalid", "not enough rights")):
        return True
    if BasePlatformAdapter._is_retryable_error(error):
        return False
    if any(p in error for p in ("timed out", "readtimeout", "writetimeout", "server disconnected", "temporarily unavailable", "temporary failure")):
        return False
    return True

Environment

  • Platform: Telegram gateway
  • Component: gateway tool progress message editing
  • Repository: NousResearch/hermes-agent

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING