Skip to content

Add retry logic for failed Telegram message sends #17521

@okhan1980

Description

@okhan1980

Problem

When OpenClaw attempts to send a Telegram message (sendMessage, sendChatAction) and the network request fails transiently, the message is permanently lost with no retry.

From gateway.err.log:

[telegram] sendMessage failed: Network request for 'sendMessage' failed!
[telegram] final reply failed: HttpError: Network request for 'sendMessage' failed!

Over 16 days of logs, there were 9 confirmed lost outbound messages out of ~1,732 total fetch failures (most being benign long-poll reconnections). The lost messages are replies to the user that simply never arrive — no notification, no queue, no retry.

Impact

  • User sends a message, gets no reply, has to ask again
  • Cron job results can be silently lost
  • Sub-agent completion notifications disappear
  • No way to know a message was dropped unless the user notices

Suggested Behavior

  1. On transient network failure (TypeError: fetch failed, 5xx, timeout), retry the send with exponential backoff (e.g., 1s, 3s, 10s — 3 attempts max)
  2. If all retries fail, queue the message to a local file (e.g., pending-messages.json) for delivery on next successful connection
  3. Optionally log dropped messages so the agent can detect and re-send on heartbeat

Environment

  • OpenClaw running as gateway daemon on macOS
  • Telegram channel via long-polling (not webhook)
  • Network is generally stable (Wi-Fi, caffeinate active) but has brief transient drops (~1 per 2 days that hits an outbound send)

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions