Skip to content

fix: retry transient Telegram direct sends#9101

Closed
corazzione wants to merge 1 commit into
NousResearch:mainfrom
corazzione:fix-telegram-direct-send-retry
Closed

fix: retry transient Telegram direct sends#9101
corazzione wants to merge 1 commit into
NousResearch:mainfrom
corazzione:fix-telegram-direct-send-retry

Conversation

@corazzione

Copy link
Copy Markdown
Contributor

Summary

  • Retry transient Telegram text-send failures in the direct send path.
  • Honor retry_after when present and retry common 429/5xx responses with backoff.
  • Keep timeout-like errors non-retried to avoid duplicate delivery risk.

Root cause

The gateway adapter already has retry handling for transient Telegram delivery failures, but the direct send_message Telegram path only retried parse-mode failures. A single transient 502 or 429 could therefore fail an otherwise valid delivery.

Changes

  • Added a small retry helper around Telegram send_message calls used by the direct send path.
  • Reused it for both formatted text and plain-text fallback sends.
  • Added regression coverage for a 502 followed by a successful retry.

Validation

  • python -m pytest tests/tools/test_send_message_tool.py::TestSendTelegramHtmlDetection::test_transient_bad_gateway_retries_text_send -q -n0 (failed before the code change, passed after)
  • python -m pytest tests/tools/test_send_message_tool.py::TestSendTelegramHtmlDetection -q -n0
  • python -m pytest tests/tools/test_send_message_tool.py -q -n0
  • python -m py_compile tools/send_message_tool.py tests/tools/test_send_message_tool.py
  • git diff --check

Refs #8844

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #10947. Your commit was cherry-picked onto current main with authorship preserved. Thanks @corazzione!

@teknium1 teknium1 closed this Apr 16, 2026
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.

2 participants