Description
When send_message is called with target="wecom" and a MEDIA:<file_path> directive, the media file is silently dropped — only the text message is delivered.
Root Cause
In _send_to_platform() (tools/send_message_tool.py), when WeCom has media_files, there is no dedicated branch to handle them. The flow falls through all platform-specific media branches (Telegram, Weixin, Discord, Matrix, Signal, Feishu) into the "Non-media platforms" catch-all (line 825-838), which discards media_files with a warning and proceeds to _send_wecom() for text-only delivery.
Meanwhile, _send_wecom() creates its own WeComAdapter instance and attempts a fresh WebSocket connection. WeCom enforces a single-WebSocket-per-bot policy, so this standalone connection fails with errcode 846609: aibot websocket not subscribed when the gateway is already running.
Proposed Fix
Add a Platform.WECOM and media_files branch in _send_to_platform() (after the Feishu branch, before "Non-media platforms") that routes through _send_via_adapter(), which:
- Grabs the live WeComAdapter from the running gateway (via
_gateway_runner_ref())
- Temporarily clears
_last_chat_req_ids so the adapter falls through to proactive send mode
- Calls
adapter.send_document(chat_id, file_path) for non-image files / adapter.send_image_file() for images
- Calls
adapter.send(chat_id, content) for the text message
- Restores
_last_chat_req_ids so the gateway's response delivery is unaffected
This avoids the WebSocket conflict because it reuses the gateway's existing connection.
Code Location
tools/send_message_tool.py, _send_to_platform() function (around line 807)
- New branch for
Platform.WECOM and media_files needed between Feishu media branch (line 788) and "Non-media platforms" catch-all (line 825)
Related
Description
When
send_messageis called withtarget="wecom"and aMEDIA:<file_path>directive, the media file is silently dropped — only the text message is delivered.Root Cause
In
_send_to_platform()(tools/send_message_tool.py), when WeCom hasmedia_files, there is no dedicated branch to handle them. The flow falls through all platform-specific media branches (Telegram, Weixin, Discord, Matrix, Signal, Feishu) into the "Non-media platforms" catch-all (line 825-838), which discardsmedia_fileswith a warning and proceeds to_send_wecom()for text-only delivery.Meanwhile,
_send_wecom()creates its ownWeComAdapterinstance and attempts a fresh WebSocket connection. WeCom enforces a single-WebSocket-per-bot policy, so this standalone connection fails witherrcode 846609: aibot websocket not subscribedwhen the gateway is already running.Proposed Fix
Add a
Platform.WECOM and media_filesbranch in_send_to_platform()(after the Feishu branch, before "Non-media platforms") that routes through_send_via_adapter(), which:_gateway_runner_ref())_last_chat_req_idsso the adapter falls through to proactive send modeadapter.send_document(chat_id, file_path)for non-image files /adapter.send_image_file()for imagesadapter.send(chat_id, content)for the text message_last_chat_req_idsso the gateway's response delivery is unaffectedThis avoids the WebSocket conflict because it reuses the gateway's existing connection.
Code Location
tools/send_message_tool.py,_send_to_platform()function (around line 807)Platform.WECOM and media_filesneeded between Feishu media branch (line 788) and "Non-media platforms" catch-all (line 825)Related