You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Weixin send_message fails with event-loop errors in non-gateway sessions (v0.11.0)Β #18437
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)
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.
This appears to be fixed on current main by the dedicated Weixin cross-loop session guard.
Automated hermes-sweeper review evidence:
gateway/platforms/weixin.py:2286-2290 now only reuses _LIVE_ADAPTERS when the live adapter's _send_session is open and send_session._loop is asyncio.get_running_loop().
If that loop check fails, gateway/platforms/weixin.py:2315-2334 falls through to a fresh aiohttp.ClientSession + WeixinAdapter in the calling context, which is the fallback requested in the issue.
tools/send_message_tool.py:598-599 routes Weixin send_message calls, including media, through _send_weixin() β send_weixin_direct().
The fixing commit is a22465e07ab4b71019f711e7a6463f6590c50742 (fix(weixin): send_weixin_direct cross-loop session check), whose commit message describes the exact reported failure mode: _run_async worker loop plus gateway-owned aiohttp session reuse causing Timeout context manager should be used inside a task.
The earliest normal release tag I found containing that commit is v2026.5.7.
Thanks for the detailed root-cause writeup and timeline; it matches the fix that landed after the reported v2026.4.23 build.
Activity
alt-glitch commentedon May 1, 2026
Likely duplicate of #13281 / #17595 β same root cause: cross-event-loop aiohttp session reuse in send_weixin_direct(). Fix PRs already open: #14873, #12810.
alt-glitch commentedon May 1, 2026
Likely duplicate of #13281 / #17595 β same root cause: cross-event-loop aiohttp session reuse in send_weixin_direct(). Fix PRs already open: #14873, #12810.
fix(weixin): avoid cross-event-loop reuse of live gateway adapter in β¦
teknium1 commentedon Jun 10, 2026
This appears to be fixed on current
mainby the dedicated Weixin cross-loop session guard.Automated hermes-sweeper review evidence:
gateway/platforms/weixin.py:2286-2290now only reuses_LIVE_ADAPTERSwhen the live adapter's_send_sessionis open andsend_session._loop is asyncio.get_running_loop().gateway/platforms/weixin.py:2315-2334falls through to a freshaiohttp.ClientSession+WeixinAdapterin the calling context, which is the fallback requested in the issue.tools/send_message_tool.py:598-599routes Weixinsend_messagecalls, including media, through_send_weixin()βsend_weixin_direct().a22465e07ab4b71019f711e7a6463f6590c50742(fix(weixin): send_weixin_direct cross-loop session check), whose commit message describes the exact reported failure mode:_run_asyncworker loop plus gateway-owned aiohttp session reuse causingTimeout context manager should be used inside a task.v2026.5.7.Thanks for the detailed root-cause writeup and timeline; it matches the fix that landed after the reported
v2026.4.23build.