Skip to content

fix(telegram): add missing 'action' retry context for sendChatAction#100762

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
lzw112:fix/telegram-add-action-retry-context
Jul 6, 2026
Merged

fix(telegram): add missing 'action' retry context for sendChatAction#100762
vincentkoc merged 3 commits into
openclaw:mainfrom
lzw112:fix/telegram-add-action-retry-context

Conversation

@lzw112

@lzw112 lzw112 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

isTransientSendChatActionError passes context: "send" to isRecoverableTelegramNetworkError, which means snippet-only transient errors (e.g. "socket hang up", "undici") that lack a specific error code are not retried. Every other idempotent caller in the send funnel uses a permissive context — "delete" for deleteMessage, "react" for setMessageReaction, "edit" for editMessageText. The sendChatAction path was the only remaining caller that used the strict "send" context despite being idempotent, making its retry policy inconsistent with siblings.

Why This Change Was Made

sendChatAction (typing indicator) is semantically idempotent — retrying it cannot produce a duplicate visible message. Even if Telegram receives the request twice, the user only sees a typing indicator that expires after a few seconds. Transient network errors that lack an error code (e.g. socket hang up) should trigger a retry.

Adding "action" to TelegramNetworkErrorContext and using it in isTransientSendChatActionError makes the retry policy explicit and consistent:

operation context allowMessageMatch
sendMessage "send" false (strict)
deleteMessage "delete" true
setMessageReaction "react" true
editMessageText "edit" true
sendChatAction "action" (new) true

There is zero behavioral change for coded recoverable errors (ECONNREFUSED, ENOTFOUND, etc. already retried under "send"). The change only expands retry coverage to snippet-only transient errors where the error code is absent.

User Impact

sendChatAction is more reliable on flaky networks — typing indicators survive transient socket errors instead of being silently dropped. No breaking change: "send" for sendMessage stays strict to guard against duplicate messages.

Evidence

Verified against commit 08749aa188 on branch fix/telegram-add-action-retry-context.

scenario: transient snippet-only network errors (no error code)
fix: action context must retry like delete/react/edit

err="Undici: socket failure" (no error code)
    send (non-idempotent)        context:"send"    => false PASS
    delete (idempotent baseline) context:"delete"  => true  PASS
    react (idempotent baseline)  context:"react"   => true  PASS
    edit (idempotent baseline)   context:"edit"    => true  PASS
    action (idempotent FIX)      context:"action"  => true  PASS

err="socket hang up" (no error code)
    send                         context:"send"    => false PASS
    action                       context:"action"  => true  PASS

err=ECONNREFUSED (has error code)
    send                         context:"send"    => true  PASS
    action                       context:"action"  => true  PASS

err="invalid token" (non-network)
    send                         context:"send"    => false PASS
    action                       context:"action"  => false PASS

Verdict: PASS"action" context returns recoverable for snippet-only transient errors, matching "delete" / "react" / "edit". "send" stays strict. Coded recoverable errors (ECONNREFUSED) retry across all contexts; non-network errors (invalid token) never retry.

Tests and Validation

$ pnpm test extensions/telegram/src/network-errors.test.ts
Test Files  1 passed (1)
Tests       58 passed (58)

One regression assertion added: "action" context treats snippet-only errors as recoverable (matching "delete" / "react" / "edit"), while "send" stays strict.

Risk Checklist

  • User-visible behavior: No — sendChatAction retries more reliably on flaky networks; no regression for sendMessage.
  • Config/env/migration behavior: No.
  • Security/auth/secrets/network/tool execution: No.
  • Plugins/providers/channels/SDK: No — internal to Telegram plugin.
  • Highest-risk area: None. The change adds one enum value and swaps a context string; isRecoverableTelegramNetworkError produces identical results for coded errors, and the expanded snippet match is gated by context.
  • Mitigation: Existing tests (58) + new regression case guard semantics; sendMessage keeps "send" (strict).

Closes: N/A

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS labels Jul 6, 2026
@lzw112 lzw112 closed this Jul 6, 2026
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@vincentkoc vincentkoc reopened this Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer proof for exact head 9e08d29902b4bafb06620f2ebfd877e24fedeb05:

  • repaired the second sendChatAction entry path so both use the retry-safe action context
  • Node 24 focused Vitest: 3 files, 230 tests passed
  • oxfmt --check passed for all 6 changed files
  • git diff --check passed
  • independent codex review --base origin/main: no correctness regressions
  • exact-head CI and Real behavior proof are green

No broad local suite or Testbox run; Blacksmith was unavailable. The focused proof covers the classifier, cooldown wrapper, and direct typing retry while visible sends remain strict.

@vincentkoc
vincentkoc merged commit 22dfb15 into openclaw:main Jul 6, 2026
89 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…penclaw#100762)

* fix(telegram): add missing 'action' retry context for sendChatAction

* fix(telegram): cover all sendChatAction retry paths

---------

Co-authored-by: Vincent Koc <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…penclaw#100762)

* fix(telegram): add missing 'action' retry context for sendChatAction

* fix(telegram): cover all sendChatAction retry paths

---------

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants