Skip to content

Telegram DM lane can remain guarded after send timeout, delaying or dropping direct messages #91456

Closed

Description

@LibraHo

Summary

In OpenClaw 2026.6.1, Telegram direct-message delivery can become unreliable after Telegram API network timeouts. A direct-message lane may remain guarded after a failed/aborted send path, causing later DM messages to be delayed or not reflected in the target agent session until recovery.

Environment

  • OpenClaw version: 2026.6.1
  • Channel: Telegram
  • Telegram mode: polling
  • Affected route: direct DM to an agent session
  • Gateway bind: lan

Observed behavior

During a Telegram network failure window, the user sent multiple direct messages. Some inbound Telegram updates were visible in gateway logs, but the corresponding agent session did not process/respond to the messages promptly. The agent appeared unresponsive until the lane recovered and later messages created/updated a fresh session.

Relevant sanitized log patterns:

telegram sendMessage failed: Network request for 'sendMessage' failed!
telegram sendChatAction failed: Network request for 'sendChatAction' failed!
fetch fallback: DNS-resolved IP unreachable; trying alternative Telegram API IP (... request-timeout ...)
[telegram][diag] timed out spooled update <update_id> did not stop within 5s after reply abort; keeping lane telegram:<user_id> guarded.
Delivery entry <id> delivery state is send_attempt_started; refusing blind replay without adapter reconciliation
Telegram reconnect drain: retry failed ... delivery state is send_attempt_started; refusing blind replay without adapter reconciliation

There were also diagnostic stale/stalled session messages around the same time, but the user-visible failure was that direct messages appeared to be ignored or delayed.

Expected behavior

Telegram inbound updates should be durable and should not be blocked by outbound delivery failures such as sendChatAction or sendMessage timeouts.

A Telegram network timeout should at worst delay outbound delivery. It should not silently prevent later direct messages from reaching the agent session.

Why this matters

From the user's perspective, the assistant appears to stop replying even though messages were sent. This is particularly confusing because later messages may start working again, making the issue look intermittent.

Suggested fixes

  1. Make sendChatAction best-effort only. Failure should not affect inbound update processing or lane health.
  2. Persist inbound Telegram updates before outbound delivery/transcription/agent side effects.
  3. Add a bounded TTL/auto-release for guarded Telegram lanes.
  4. Reconcile send_attempt_started delivery state after reconnect instead of refusing blind replay indefinitely.
  5. Emit a visible diagnostic/system event when a DM lane is guarded due to Telegram delivery failure.

Reproduction idea

  1. Run OpenClaw with Telegram polling enabled.
  2. Open a Telegram DM to an agent.
  3. Send multiple quick DM messages.
  4. While a reply/sendChatAction is in progress, induce Telegram API timeouts, for example by blocking or delaying api.telegram.org traffic.
  5. Observe whether the DM lane enters guarded state and whether subsequent inbound messages are delayed/missing from the agent session.

Activity

  1. clawsweeper commented on Jun 8, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    The permanent guarded Telegram ingress-lane failure is fixed on current main and documented as shipped in the 2026.7.1 release line; the remaining refusal to blindly replay an ambiguous outbound send is intentional duplicate-send protection, not a reason to keep inbound DM processing blocked.

    Possible regression — probable (reproduction; failure trace). No predecessor PR is attributed.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the shipped durable ingress-drain lifecycle: adopt before reply delivery, release deferred lane occupancy, and dead-letter a bounded pre-adoption wedge without risky blind outbound replay.

    Do we have a high-confidence way to reproduce the issue?

    No current-main failure is established: the exact wedged-handler scenario is encoded in a current regression test that verifies the next same-lane update drains without restart.

    Is this the best way to solve the issue?

    Yes. The shipped repair fixes the lifecycle owner—durable ingress adoption and lane ownership—rather than treating one Telegram outbound error as a special case.

    Security review:

    Security review: No patch is under review.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Likely related people:

    • Ayaan Zaidi: Authored the history commit matching the adoption and watchdog repair later represented by the shared ingress-drain implementation. (role: durable-adoption change author; confidence: high; commits: 77c84de5109a, fc6b9dad0b13; files: src/channels/message/ingress-drain.ts, extensions/telegram/src/telegram-ingress-drain.ts)
    • Vincent Koc: Release records credit this area’s turn-adoption hardening, and history includes the stalled-claim recovery work that preceded the shared drain. (role: recent Telegram reliability contributor; confidence: medium; commits: b8e3de11608d, f79e8859855b; files: extensions/telegram/src/polling-session.ts, extensions/telegram/src/polling-session.test.ts)

    Codex review notes: model internal, reasoning high; reviewed against 5e477aff2adc; fix evidence: release 2026.7.1, commit 77c84de5109a.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jun 8, 2026
  3. anguslogan01 commented on Jun 12, 2026

    @anguslogan01

    Live repro — same guarded-lane failure mode, reached via a non-network inbound trigger

    Hit this on OpenClaw 2026.5.28 (e932160), Telegram polling, direct DM lane. Exact signature line from this issue is present:

    [telegram][diag] timed out spooled update <update_id> did not stop within 5s after reply abort; keeping lane telegram:<user_id> guarded.
    

    Key difference from the original report

    This issue is framed around outbound failures (sendMessage / sendChatAction network timeouts). In my repro there was no outbound network failure. The trigger was an inbound reply handler that ran for 1500s and hit a hard handler-timeout, then failed to abort cleanly:

    spool handler timed out behind update <update_id> on lane telegram:<user_id> after 1500.31s;
    marking the update failed, aborting active reply work, and restarting isolated ingress so later updates can drain.
    

    Failed spool entry:

    {"version":1,"updateId":<update_id>,"failure":{"reason":"handler-timeout",
    "message":"...timed out... after 1500.31s; marking the update failed, aborting active reply work, and restarting isolated ingress..."}}

    So the same guarded-lane / message-loss end state is reachable without any Telegram API timeout — a single stuck reply handler (e.g. a hung model stream during reply generation) is enough. A fix scoped only to the outbound path (suggested fix #1, "make sendChatAction best-effort") would not cover this path.

    Observed behavior

    • Inbound update N reply hangs 25 min → handler-timeout → lane guarded.
    • Abort "did not stop within 5s after reply abort" → lane kept guarded.
    • Ingress offset frozen at N-1; updates N+1 … N+4 accumulate in the spool, never processed.
    • Channel status shows disconnected, in:16h ago with the handler-timeout error sticky on the channel.

    The restart loop does not recover it (additional finding)

    The Telegram health-monitor detected disconnected and auto-restarted the provider every ~10–15 min for ~16 hours / ~30 attempts:

    [health-monitor] [telegram:default] health-monitor: restarting (reason: disconnected)
    [telegram] [default] auto-restart attempt 1/10 in 5s
    [telegram] [diag] isolated polling ingress started spool=.../telegram/ingress-spool-default
    

    None cleared the guard. The orphaned reply promise from the timed-out handler is still pending in the Node process, so only a full gateway process restart releases the lane and drains the spool. Provider-level restart is insufficient.

    Suggested scope additions

    • Generalize suggested fix WA business, groups & office hours  #3 (bounded TTL / auto-release for guarded lanes) so the guard self-clears regardless of why it was set — this single fix covers both the outbound-timeout and the inbound-handler-timeout triggers.
    • When a reply handler abort cannot stop in-flight work within the grace window, release the lane anyway (fail the one update) rather than guarding the whole lane indefinitely.
    • Surface a visible system event when a lane stays guarded > N minutes — currently the only signal is channels status --deep; gateway /health stays live, so external watchdogs report green while DMs are silently dropped.

    Repro (no network manipulation needed)

    1. Telegram polling, DM to an agent.
    2. Cause one reply handler to hang past the handler-timeout ceiling (e.g. a model stream that never returns).
    3. Observe the lane go guarded and stay guarded across provider auto-restarts; subsequent inbound DMs spool but never reach the session until a full gateway process restart.

    (All IDs/message contents redacted.)

  4. added
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    and removed
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jun 19, 2026
  5. 6 remaining items

  6. added
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    and removed
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jul 30, 2026
  7. obviyus commented on Aug 13, 2026

    @obviyus
    Collaborator

    Thanks for the detailed report. This is fixed on current main: a timed-out update is now dead-lettered, and the next DM in the same lane drains without a restart. Verified with the focused Telegram polling-session regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions