Skip to content

fix: recover from transient reply failures - #242

Open
FrundlesTian wants to merge 2 commits into
overwirehq:mainfrom
FrundlesTian:fix/connection-reply-reliability
Open

FrundlesTian wants to merge 2 commits into
overwirehq:mainfrom
FrundlesTian:fix/connection-reply-reliability

Conversation

@FrundlesTian

Copy link
Copy Markdown
Collaborator

Description

Prevent intermittent Telegram requests from finishing without a delivered reply.

  • retry transient Telegram NetworkError/TimedOut failures with bounded exponential backoff
  • keep invalid-markup fallback separate so permanent BadRequest failures are not retried
  • make typing indicators and progress-message deletion non-fatal
  • retry progress, final-response, classic-handler error, and global error messages
  • require the Claude SDK stream to end with ResultMessage
  • retry only a completely empty SDK stream; do not replay a partially observed stream because tool side effects may already have happened
  • configure the separate getUpdates client with the explicit proxy

This is stacked on #236 and currently includes #240 (4f62dc2). The connection-stability implementation is commit 0b8c8e2; once #240 lands, this branch can be rebased without changing the fix.

Related issue

Closes #241

Type of change

  • Bug fix
  • New feature
  • Breaking change (documented in CHANGELOG under "Changed" or "Removed")
  • Documentation or tooling only

How it was tested

  • Tests added or updated
  • pytest -q — 690 passed
  • black --check src tests
  • isort --check-only src tests
  • flake8 src tests
  • Tested by hand against a running bot

The regression tests cover transient recovery, retry exhaustion, permanent BadRequest, empty SDK EOF recovery, partial-stream non-replay, and proxy wiring for both PTB clients.

Checklist

  • One concern per PR; unrelated changes are split out
  • CHANGELOG.md has an entry under [Unreleased]
  • No dependency changes
  • No settings or command documentation changes required
  • New settings default to current behaviour (no new settings)
  • AI-assisted changes were reviewed line-by-line; no end-to-end bot claim is made

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
  • Unrelated concerns bundled (CHANGELOG.md:11, src/claude/sdk_integration.py:804): the OpenRouter empty-ResultMessage.result fallback (Bug: "No content to display" when using OpenRouter as backend #171) has nothing to do with Telegram send retries, the getUpdates proxy, or the SDK incomplete-stream retry (Bug: transient connection failures can leave Telegram requests without a final reply #241). Split the Bug: "No content to display" when using OpenRouter as backend #171 fix into its own PR.
  • Send fallback narrowed from Exception to BadRequest, with no test (src/bot/handlers/message.py:520, src/bot/orchestrator.py:1194): the plain-text fallback used to run on any send error. Now RetryAfter, Forbidden or a NetworkError that outlasts the 3 attempts skip it and go to the outer handler, so the whole reply is dropped and the user gets a generic error. No test covers the changed branches in handle_text_message or agentic_text.
  • Retrying reply_text on TimedOut can duplicate replies (src/bot/utils/telegram_retry.py:362): TimedOut and NetworkError don't mean the message wasn't delivered. If Telegram accepted the send but the response was lost, the retry posts the same reply twice. This is most visible on multi-part responses.

@RichardAtCT
RichardAtCT changed the base branch from claude/report-run-stop-reason-zfw34i to main October 1, 2026 07:44
@FrundlesTian
FrundlesTian force-pushed the fix/connection-reply-reliability branch from 0b8c8e2 to 81f2d2c Compare October 22, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: transient connection failures can leave Telegram requests without a final reply

1 participant