ποΈ Bug: Weixin send_message tool fails with event-loop errors in non-gateway sessions
Hermes Version: v0.11.0 (2026.4.23)
Platform: Weixin (Enterprise WeChat / iLink)
Python: 3.11.15
websockets: 15.0.1 (downgraded to 14.0)
Description
The send_message tool (send_document / send_image_file) fails when called from CLI or cron contexts. Gateway text sends work fine, but media sends fail with:
websockets 15.x: Timeout context manager should be used inside a task
websockets 14.x: Future <Future pending> attached to a different loop
Steps to Reproduce
- Run
hermes weixin
- Call
send_message with media: action=send, platform=weixin, target=weixin:<chat_id>, message=MEDIA:/path/to/file.png
- Tool returns event-loop error; gateway text sends work fine
Root cause: _handle_send() -> _run_async() -> _send_to_platform() -> _send_weixin() -> send_weixin_direct() -> tries to reuse _LIVE_ADAPTERS (gateway WeixinAdapter) running in a different event loop (ThreadPoolExecutor -> asyncio.run() creates a new loop).
Affected Timeline
| Date |
Observation |
| Apr 28 |
First Timeout context manager errors in background agents |
| Apr 30 23:41 |
Image send succeeded via gateway own session (not tool call) |
| May 1 |
Same errors; text OK, media fails |
| May 1 (ws 14.0) |
Different error symptom, same root cause |
Environment
Hermes Agent v0.11.0 (2026.4.23)
Python: 3.11.15 websockets: 14.0
gateway: weixin connected
Key files:
gateway/platforms/weixin.py - send_weixin_direct()
tools/send_message_tool.py - _send_to_platform()
model_tools.py - _run_async()
Suggested Fix
When _LIVE_ADAPTERS is unavailable or in the wrong loop, send_weixin_direct() should fall back to creating a fresh aiohttp.ClientSession + WeixinAdapter in the calling context, instead of trying to reuse the gateway adapter from a different event loop.
ποΈ Bug: Weixin send_message tool fails with event-loop errors in non-gateway sessions
Hermes Version: v0.11.0 (2026.4.23)
Platform: Weixin (Enterprise WeChat / iLink)
Python: 3.11.15
websockets: 15.0.1 (downgraded to 14.0)
Description
The
send_messagetool (send_document/send_image_file) fails when called from CLI or cron contexts. Gateway text sends work fine, but media sends fail with:websockets 15.x:
Timeout context manager should be used inside a taskwebsockets 14.x:
Future <Future pending> attached to a different loopSteps to Reproduce
hermes weixinsend_messagewith media:action=send,platform=weixin,target=weixin:<chat_id>,message=MEDIA:/path/to/file.pngRoot cause:
_handle_send()->_run_async()->_send_to_platform()->_send_weixin()->send_weixin_direct()-> tries to reuse_LIVE_ADAPTERS(gateway WeixinAdapter) running in a different event loop (ThreadPoolExecutor ->asyncio.run()creates a new loop).Affected Timeline
Timeout context managererrors in background agentsEnvironment
Key files:
gateway/platforms/weixin.py-send_weixin_direct()tools/send_message_tool.py-_send_to_platform()model_tools.py-_run_async()Suggested Fix
When
_LIVE_ADAPTERSis unavailable or in the wrong loop,send_weixin_direct()should fall back to creating a freshaiohttp.ClientSession+WeixinAdapterin the calling context, instead of trying to reuse the gateway adapter from a different event loop.