Skip to content

[WeCom] send_message MEDIA files silently dropped — no media branch in _send_to_platform #37364

@changyinhui

Description

@changyinhui

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:

  1. Grabs the live WeComAdapter from the running gateway (via _gateway_runner_ref())
  2. Temporarily clears _last_chat_req_ids so the adapter falls through to proactive send mode
  3. Calls adapter.send_document(chat_id, file_path) for non-image files / adapter.send_image_file() for images
  4. Calls adapter.send(chat_id, content) for the text message
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsplatform/wecomWeCom / WeChat Work adaptertool/webWeb search and extractiontype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions