Skip to content

fix(send_message): route standalone Telegram sends through TELEGRAM_PROXY#28480

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-6063e704
May 19, 2026
Merged

fix(send_message): route standalone Telegram sends through TELEGRAM_PROXY#28480
teknium1 merged 2 commits into
mainfrom
hermes/hermes-6063e704

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #25419 (@pepelax).

Summary

In regions where api.telegram.org is blocked, calling the send_message tool from any process other than the gateway itself (agent loop, TUI, cron, ad-hoc scripts) silently failed with a 5s timeout — no entry in gateway.log because the request never reached the gateway. tools/send_message_tool.py::_send_telegram constructed Bot(token=token) with no proxy, even though the gateway adapter resolved TELEGRAM_PROXY for in-process calls. Affects both text and media sends.

Changes

  • tools/send_message_tool.py: pass TELEGRAM_PROXY via HTTPXRequest when the in-process delegation path isn't available.
  • tests/tools/test_send_message_telegram_proxy.py: coverage.

Validation

  • scripts/run_tests.sh tests/tools/test_send_message_telegram_proxy.py -q → 2/2 passing.

Also supersedes #27701 (@leolulu) which fixed the media-only subset — closed with credit.

Authorship preserved via cherry-pick. AUTHOR_MAP entry added in follow-up commit.

pepelax and others added 2 commits May 18, 2026 21:54
…ROXY

When the send_message tool runs outside the gateway process (agent loop,
TUI, cron, etc.), _gateway_runner_ref() returns None and the standalone
path in _send_telegram constructs Bot(token=token) directly, bypassing
any configured proxy. In regions where api.telegram.org is blocked, the
send times out after ~5s with 'Telegram send failed: Timed out' and
nothing ever shows up in gateway.log because the request never reaches
the gateway.

Resolve TELEGRAM_PROXY (via gateway.platforms.base.resolve_proxy_url,
which also honours HTTPS_PROXY/HTTP_PROXY/ALL_PROXY and NO_PROXY) just
before constructing the Bot. When a proxy is found, attach an
HTTPXRequest(proxy=...) for both 'request' and 'get_updates_request',
matching what gateway/platforms/telegram.py already does for in-gateway
sends and what the Discord standalone sender already does. Any
exception attaching the proxy falls back cleanly to a direct connection,
preserving prior behaviour for users without a proxy configured.

Adds tests/tools/test_send_message_telegram_proxy.py covering both the
proxy-configured and no-proxy cases.
@teknium1 teknium1 merged commit b58b418 into main May 19, 2026
@teknium1 teknium1 deleted the hermes/hermes-6063e704 branch May 19, 2026 04:54
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-6063e704 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8880 on HEAD, 8878 on base (🆕 +2)

🆕 New issues (2):

Rule Count
unresolved-import 2
First entries
tools/send_message_tool.py:831: [unresolved-import] unresolved-import: Cannot resolve imported module `telegram.request`
tests/tools/test_send_message_telegram_proxy.py:23: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`

✅ Fixed issues: none

Unchanged: 4649 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets platform/telegram Telegram bot adapter labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants