hermes - 💡(How to fix) Fix [Bug] Weixin Gateway: Timeout context manager should be used inside a task [2 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#18836Fetched 2026-05-03 04:53:59
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2

Error Message

Weixin (微信) gateway fails to send messages with the following error: ERROR gateway.platforms.weixin: [Weixin] send failed to=o9cq80zn: Timeout context manager should be used inside a task 4. Error occurs immediately 2026-05-02 21:16:09,143 ERROR gateway.platforms.weixin: [Weixin] send failed to=o9cq80zn: Timeout context manager should be used inside a task The error message suggests that asyncio.timeout() or similar async context manager is being used in a synchronous context or outside of a proper async task. This is a common issue when mixing sync/async code incorrectly.

Fix Action

Fix / Workaround

Current Workaround: Use other platforms (Telegram, Yuanbao, Feishu) for file/message delivery.

Code Example

ERROR gateway.platforms.weixin: [Weixin] send failed to=o9cq80zn: Timeout context manager should be used inside a task

---

2026-05-02 21:16:03,131 WARNING gateway.platforms.weixin: [Weixin] send chunk failed to=o9cq80zn attempt=1/4, retrying in 1.00s: Timeout context manager should be used inside a task
2026-05-02 21:16:04,135 WARNING gateway.platforms.weixin: [Weixin] send chunk failed to=o9cq80zn attempt=2/4, retrying in 2.00s: Timeout context manager should be used inside a task
2026-05-02 21:16:06,139 WARNING gateway.platforms.weixin: [Weixin] send chunk failed to=o9cq80zn attempt=3/4, retrying in 3.00s: Timeout context manager should be used inside a task
2026-05-02 21:16:09,143 ERROR gateway.platforms.weixin: [Weixin] send failed to=o9cq80zn: Timeout context manager should be used inside a task
RAW_BUFFERClick to expand / collapse

Bug Description

Weixin (微信) gateway fails to send messages with the following error:

ERROR gateway.platforms.weixin: [Weixin] send failed to=o9cq80zn: Timeout context manager should be used inside a task

This is an asyncio context manager usage bug where asyncio.timeout() or similar is being used outside of an async task context.

Steps to Reproduce

  1. Configure Weixin gateway in ~/.hermes/config.yaml
  2. Start gateway: hermes gateway start
  3. Attempt to send a message via send_message tool with target="weixin"
  4. Error occurs immediately

Expected Behavior

Message should be sent successfully to Weixin, similar to how Telegram, Yuanbao, and other platforms work.

Actual Behavior

2026-05-02 21:16:03,131 WARNING gateway.platforms.weixin: [Weixin] send chunk failed to=o9cq80zn attempt=1/4, retrying in 1.00s: Timeout context manager should be used inside a task
2026-05-02 21:16:04,135 WARNING gateway.platforms.weixin: [Weixin] send chunk failed to=o9cq80zn attempt=2/4, retrying in 2.00s: Timeout context manager should be used inside a task
2026-05-02 21:16:06,139 WARNING gateway.platforms.weixin: [Weixin] send chunk failed to=o9cq80zn attempt=3/4, retrying in 3.00s: Timeout context manager should be used inside a task
2026-05-02 21:16:09,143 ERROR gateway.platforms.weixin: [Weixin] send failed to=o9cq80zn: Timeout context manager should be used inside a task

Environment

  • Hermes Version: Latest from main branch
  • Python Version: 3.9
  • Platform: macOS (Apple Silicon)
  • WeChat Client: Running in background

Additional Context

Other platforms (Telegram, Yuanbao, Feishu) work correctly. Only Weixin is affected.

The error message suggests that asyncio.timeout() or similar async context manager is being used in a synchronous context or outside of a proper async task. This is a common issue when mixing sync/async code incorrectly.

Possible Fix

Check gateway/platforms/weixin.py for usage of asyncio.timeout() or similar context managers. Ensure they are used within proper async functions that are being awaited correctly.

Related Python docs: https://docs.python.org/3/library/asyncio-task.html#asyncio.timeout


Current Workaround: Use other platforms (Telegram, Yuanbao, Feishu) for file/message delivery.

extent analysis

TL;DR

The most likely fix is to ensure that asyncio.timeout() or similar context managers are used within proper async functions in gateway/platforms/weixin.py.

Guidance

  • Review gateway/platforms/weixin.py for incorrect usage of asyncio.timeout() or similar async context managers.
  • Verify that all async functions using these context managers are properly awaited.
  • Check for any mixing of synchronous and asynchronous code that could be causing the issue.
  • Consider using a debugger or adding logging statements to identify the specific line of code causing the error.

Example

No code snippet is provided as the issue is more related to the usage of async context managers rather than a specific code block.

Notes

The issue seems to be specific to the Weixin platform, and other platforms like Telegram, Yuanbao, and Feishu are working correctly. This suggests that the problem is likely related to the implementation of the Weixin gateway rather than a general issue with the Hermes application.

Recommendation

Apply workaround: Use other platforms (Telegram, Yuanbao, Feishu) for file/message delivery until the issue with the Weixin gateway is resolved. This is because the root cause of the issue is related to the incorrect usage of async context managers, which requires a code fix.

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