fix(telegram): honor HERMES_TELEGRAM_HTTP_* timeouts in standalone send path - #77315
Open
garyyang1001 wants to merge 1 commit into
Open
garyyang1001 wants to merge 1 commit into
garyyang1001 wants to merge 1 commit into
Conversation
…nd path The standalone _send_telegram path (agent / TUI / cron / hermes send) constructs its own telegram.Bot with PTB's default HTTPXRequest, which times every request out at 5s. Telegram can hold sendDocument/sendPhoto responses for 30s+ when a bot is under flood control, so every standalone media send fails with 'Timed out' (surfaced as 'No deliverable text or media remained after processing MEDIA tags') even though the upload succeeds server-side. The in-gateway adapter already exposes HERMES_TELEGRAM_HTTP_POOL/ CONNECT/READ/WRITE_TIMEOUT env knobs with saner defaults (8/10/20/20s). Honor the same knobs, with the same defaults, in the standalone path so the two send paths behave consistently and operators can raise the ceiling without patching code.
garyyang1001
force-pushed
the
fix/standalone-telegram-send-timeouts
branch
from
August 4, 2026 15:31
4fa0eec to
950da72
Compare
garyyang1001
added a commit
to garyyang1001/hermes-agent
that referenced
this pull request
Aug 4, 2026
…e120) Telegram can hold sendDocument responses for 30s+ under flood control; PTB's 5s default read timeout then fails every standalone media send. Aligns with the gateway adapter's HERMES_TELEGRAM_HTTP_*_TIMEOUT knobs. Superseded upstream by NousResearch#77315. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Makes the standalone Telegram send path (
tools/send_message_tool.py::_send_telegram, used by agent / TUI / cron /hermes send) honor the sameHERMES_TELEGRAM_HTTP_*timeout env knobs as the in-gateway adapter, with the same defaults (pool 8s / connect 10s / read 20s / write 20s).Today that path constructs
telegram.Bot(token=...)with PTB's defaultHTTPXRequest, which times every request out at 5s. Telegram can holdsendDocument/sendPhotoresponses for 30s+ when a bot is under flood control, so every standalone media send fails withTimed out— surfaced to the caller as the misleadingNo deliverable text or media remained after processing MEDIA tags— even though the upload itself succeeds server-side (risking silent duplicates on retry).Real-world incident: a production deployment lost two days of scheduled document deliveries (all
hermes sendMEDIA pushes timing out every 5-minute retry sweep) whilecurluploads of the same files completed in <2s. Raising the read timeout via the (previously gateway-only) env knob fixed it — this PR makes that knob work for the standalone path too, and aligns the defaults so the two send paths behave consistently.Related Issue
No existing issue found (searched
telegram timeout,send_message_tool timeout,telegram media timed out; closed PRs #47238/#47923 addressed retry for text sends, not the media/HTTPXRequesttimeout configuration).Type of Change
Changes Made
tools/send_message_tool.py— standaloneBot()construction now buildsHTTPXRequestwithHERMES_TELEGRAM_HTTP_POOL/CONNECT/READ/WRITE_TIMEOUT(defaults matchingplugins/platforms/telegram/adapter.py: 8/10/20/20s), on both the proxy and direct branches. Malformed env values fall back to defaults. Iftelegram.requestis unavailable, falls back to a plainBot(token=...)as before.tests/tools/test_send_message_telegram_timeouts.py— new: default values, env overrides, malformed-env fallback, proxy branch carrying timeouts.tests/tools/test_send_message_telegram_proxy.py— updatedtest_no_proxy_env_uses_plain_botto the new contract (direct branch passes a timeout-tunedrequest=, still noproxy=, still noget_updates_request=).How to Test
pytest tests/tools/test_send_message_telegram_timeouts.py tests/tools/test_send_message_telegram_proxy.py -q→ 6 passed.HERMES_TELEGRAM_HTTP_READ_TIMEOUT=1to simulate), runhermes send --to telegram:<chat> "hi MEDIA:/path/to/file.docx"→ fails withTimed outbefore this fix at default settings when Telegram responds slowly.HERMES_TELEGRAM_HTTP_READ_TIMEOUT=120in~/.hermes/.env→ same command delivers.Checklist
Code
fix(telegram): ...)pytest tests/tools/ -q— the tests touching this area all pass; the 60 pre-existing failures on my machine (voice/wake-word/web-tools env-dependent) fail identically on a pristineorigin/maincheckoutDocumentation & Housekeeping
cli-config.yaml.example: N/A — no config keys addedCONTRIBUTING.md/AGENTS.md: N/A