Skip to content

fix(weixin): skip live_adapter session reuse in send_weixin_direct#16790

Open
mannex111 wants to merge 1 commit into
NousResearch:mainfrom
mannex111:fix/weixin-send-document-event-loop
Open

fix(weixin): skip live_adapter session reuse in send_weixin_direct#16790
mannex111 wants to merge 1 commit into
NousResearch:mainfrom
mannex111:fix/weixin-send-document-event-loop

Conversation

@mannex111

Copy link
Copy Markdown

Problem

Sending files via the tool to WeChat fails with:

This happens in → .

Root Cause

The function tries to reuse the cached
session (line 1983-2008 before this fix). That session was created in the
gateway's main event loop, but tool calls it from a worker
thread via → , which creates a separate
event loop. aiohttp session operations are tied to the loop they were created
on, causing the error when called from a mismatched loop.

Fix

Skip the session reuse path entirely and always create a fresh
for each call. This ensures loop
compatibility regardless of the caller's async context.

Testing

  • Text messages (no media): continue to work via the text chunk path in the same function
  • File/image attachments: now use a freshly created session with correct loop affinity
  • No functional changes to the gateway's own WeixinAdapter lifecycle (still uses its own session)

Fixes: WeChat file/document sending via tool

The live_adapter session is bound to the gateway main event loop. When
called from a worker thread via _run_async ThreadPoolExecutor, reusing
that session causes aiohttp timeout errors. Always create a fresh
session instead.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/wecom WeCom / WeChat Work adapter labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #12810 — same root cause: cross-event-loop aiohttp session reuse in send_weixin_direct. See also #15911, #14481, #13350.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants