Skip to content

send_message_tool._send_telegram doesn't use TelegramFallbackTransport, causing delivery failures on blocked networks #20915

@vokasug

Description

@vokasug

Bug Description

Cron jobs and send_message tool calls fail to deliver messages to Telegram on networks where api.telegram.org is blocked (e.g., Russia), while the gateway's live Telegram adapter works fine.

Root Cause

The gateway's Telegram adapter (gateway/platforms/telegram.py) creates its Bot with a custom HTTPXRequest that uses TelegramFallbackTransport — this transport resolves api.telegram.org via DNS-over-HTTPS (Google/Cloudflare DoH) and falls back to hardcoded IPs like 149.154.167.220 when the system DNS returns a blocked IP.

However, tools/send_message_tool.py_send_telegram() (line ~700) creates Bot(token=token) with the default HTTPXRequest, bypassing all fallback logic:

# gateway/platforms/telegram.py — WORKS
from telegram.request import HTTPXRequest
# ... TelegramFallbackTransport injected into HTTPXRequest

# tools/send_message_tool.py — FAILS
from telegram import Bot
bot = Bot(token=token)  # default transport, no fallback

Impact

  • Cron jobs with deliver: "telegram:CHAT_ID" timeout on api.telegram.org:443
  • send_message tool calls from agents also fail on blocked networks
  • Users see curl: (28) Connection timed out or httpx.ConnectTimeout in logs
  • Gateway continues to work because it uses the fallback transport

Expected Behavior

send_message_tool._send_telegram should use the same TelegramFallbackTransport as the gateway adapter, ensuring consistent delivery regardless of network conditions.

Steps to Reproduce

  1. Run Hermes on a network where api.telegram.org is blocked
  2. Create a cron job with deliver: "telegram:CHAT_ID"
  3. Job executes but delivery fails with connection timeout
  4. Meanwhile, gateway-originated messages work fine

Suggested Fix

Make _send_telegram create Bot with the same custom HTTPXRequest that the gateway uses, or refactor to share a single create_telegram_bot() helper between gateway and send_message_tool.

Environment

  • Hermes Agent: latest main (May 2026)
  • Platform: Telegram
  • Network: api.telegram.org blocked at DNS level

Related Code

  • gateway/platforms/telegram_network.pyTelegramFallbackTransport, discover_fallback_ips()
  • gateway/platforms/telegram.py — gateway adapter with custom HTTPXRequest
  • tools/send_message_tool.py_send_telegram() line ~700
  • cron/scheduler.py_deliver_output() calls _send_to_platform_send_telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/cronCron scheduler and job managementcomp/toolsTool registry, model_tools, toolsetsplatform/telegramTelegram bot adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions