hermes - 💡(How to fix) Fix [Bug]: [CRITICAL] Multi-account Response Delay caused by Blocking Network Fallback in TelegramGateway [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#16549Fetched 2026-04-28 06:52:37
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4closed ×1commented ×1

Error Message

Additional Logs / Traceback (optional)

Root Cause

📝 Summary

Simultaneous conversations from different accounts experience significant response delays. This is caused by the TelegramFallbackTransport class performing sequential, blocking network retries when the primary Telegram API endpoint is unreachable.

Code Example

[Evidence from Log Analysis]
- Account A (chungah) encounter fallback failure at 21:38:23.
- Account B (hyewoon) sends inbound message at 21:38:39.
- Account B response completed at 21:39:03 (Total delay: ~24.6s).
- Root cause identified in: `gateway/platforms/telegram_network.py` -> `TelegramFallbackTransport.handle_async_request` using sequential `await` in a retry loop.

---
RAW_BUFFERClick to expand / collapse

Bug Description

🚨 Severity: CRITICAL

Status: Identified (Verified via Log Analysis) Component: gateway/platforms/telegram_network.py Affected Users: All multi-account users (e.g., family accounts sharing a single gateway)

📝 Summary

Simultaneous conversations from different accounts experience significant response delays. This is caused by the TelegramFallbackTransport class performing sequential, blocking network retries when the primary Telegram API endpoint is unreachable.

🔍 Root Cause Analysis

The issue resides in the handle_async_request method of the TelegramFallbackTransport class.

  • Location: .hermes/hermes-agent/gateway/platforms/telegram_network.py
  • Mechanism: When api.telegram.org connection fails, the transport enters a for loop to iterate through fallback_ips.
  • Technical Flaw: The loop uses await transport.handle_async_request(request) inside the iteration. This causes the task to block for the duration of the network timeout for each unsuccessful IP attempt.
  • Impact (Head-of-line Blocking): In a multi-account environment, this blocking behavior interferes with the gateway's ability to process other incoming messages from different accounts, leading to cascading delays across the entire gateway.

📊 Evidence (Log Trace)

Observation of concurrent activity between two accounts (chungah and hyewoon):

  1. [21:38:23] chungah account encounters: WARNING gateway.platforms.telegram_network: [Telegram] Fallback IP 149.154.167.220 failed:
  2. [21:38:39] hyewoon account sends an inbound message.
  3. [21:39:03] hyewoon account response is finally ready. Result: Total response time for hyewoon was ~24.6 seconds, directly correlated with the failure/retry period of the chungah account.

🛠 Suggested Fix

  • Asynchronous Isolation: Ensure that the retry loop for one session/account does not block the gateway's main event loop or other concurrent sessions.
  • Optimization of Retry Logic:
    • Implement more aggressive/parallelized fallback attempts.
    • Use non-blocking timeout mechanisms to prevent a single failing connection from stalling the gateway.
  • Connection Pooling/Isolation: Review how httpx.AsyncHTTPTransport instances are managed to ensure network-level isolation between different user profiles.

Steps to Reproduce

  1. Run Hermes Gateway in a multi-account environment (e.g., multiple Telegram profiles connected).
  2. Trigger a network instability or cause the primary api.telegram.org endpoint to be unreachable for one specific account (e.g., Account A).
  3. While Account A is attempting to retry connections via fallback IPs, immediately send a message from a different account (e.g., Account B).
  4. Observe the response delay for Account B.

Expected Behavior

Network retry attempts and timeouts for Account A should be handled asynchronously and isolated, so that Account B can receive responses from the Telegram API without any noticeable delay.

Actual Behavior

Account B experiences a significant response delay (e.g., ~25 seconds) because the gateway's network handler is blocked by Account A's sequential fallback retry loop. This results in Head-of-line (HOL) blocking across the gateway.

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

Telegram

Debug Report

[Evidence from Log Analysis]
- Account A (chungah) encounter fallback failure at 21:38:23.
- Account B (hyewoon) sends inbound message at 21:38:39.
- Account B response completed at 21:39:03 (Total delay: ~24.6s).
- Root cause identified in: `gateway/platforms/telegram_network.py` -> `TelegramFallbackTransport.handle_async_request` using sequential `await` in a retry loop.

Operating System

macOS (Apple Silicon / Mac Studio M4 Max)

Python Version

3.11.15

Hermes Version

v0.11.0 (2026.4.23)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

Implement asynchronous isolation and optimize the retry logic in the TelegramFallbackTransport class to prevent blocking and reduce response delays.

Guidance

  • Review the handle_async_request method in telegram_network.py to identify opportunities for asynchronous isolation and non-blocking retries.
  • Consider using parallelized fallback attempts and non-blocking timeout mechanisms to minimize the impact of a single failing connection.
  • Investigate connection pooling and isolation strategies for httpx.AsyncHTTPTransport instances to ensure network-level isolation between user profiles.
  • Test the changes using the provided steps to reproduce the issue and verify that the response delay is significantly reduced.

Example

# Pseudo-code example of parallelized fallback attempts
async def handle_async_request(self, request):
    # ...
    fallback_ips = [...]
    tasks = []
    for ip in fallback_ips:
        task = asyncio.create_task(self.retry_request(request, ip))
        tasks.append(task)
    await asyncio.gather(*tasks)
    # ...

Notes

The provided log analysis and root cause identification suggest that the issue is specific to the TelegramFallbackTransport class and can be addressed through changes to the retry logic and asynchronous handling.

Recommendation

Apply a workaround by implementing asynchronous isolation and optimizing the retry logic in the TelegramFallbackTransport class, as this will likely resolve the Head-of-line blocking issue and reduce response delays.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Bug]: [CRITICAL] Multi-account Response Delay caused by Blocking Network Fallback in TelegramGateway [1 comments, 2 participants]