hermes - 💡(How to fix) Fix 关于飞书端无法发送图片、DOCX 等附件的BUG [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#17418Fetched 2026-04-30 06:47:41
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×2

Error Message

"error": ( if isinstance(result, dict) and result.get("error"):

Fix Action

Fix / Workaround


影响范围:所有通过 send_message 向飞书发送媒体文件的场景 优先级:中(有 workaround 可用)

Code Example

elif platform == Platform.FEISHU:
    result = await _send_feishu(pconfig, chat_id, chunk, thread_id=thread_id)

---

if media_files and not message.strip():
    return {
        "error": (
            f"send_message MEDIA delivery is currently only supported for telegram, discord, matrix, weixin, signal and yuanbao; "
            f"target {platform.value} had only media attachments"
        )
    }

---

# --- Feishu: special handling for media attachments ---
if platform == Platform.FEISHU:
    last_result = None
    for i, chunk in enumerate(chunks):
        is_last = (i == len(chunks) - 1)
        result = await _send_feishu(
            pconfig,
            chat_id,
            chunk,
            media_files=media_files if is_last else [],
            thread_id=thread_id,
        )
        if isinstance(result, dict) and result.get("error"):
            return result
        last_result = result
    return last_result

---

elif platform == Platform.FEISHU:
    # 注意:这里应该传递 media_files,但现在未传递
    result = await _send_feishu(
        pconfig,
        chat_id,
        chunk,
        media_files=media_files,  # <-- 需要添加这行
        thread_id=thread_id
    )
RAW_BUFFERClick to expand / collapse

Bug 描述

send_message 工具的 _send_feishu 函数支持媒体文件发送,但实际调用时未传递 media_files 参数,导致飞书端无法发送图片、DOCX 等附件。

复现步骤

  1. 配置飞书平台
  2. 尝试用 send_message 发送带 MEDIA: 标签的图片或文件
  3. 结果:
    • 纯文字消息:✅ 正常发送
    • MEDIA 附件:❌ 被忽略,返回警告 "MEDIA attachments were omitted for feishu"

错误行号

tools/send_message_tool.py 第 595 行:

elif platform == Platform.FEISHU:
    result = await _send_feishu(pconfig, chat_id, chunk, thread_id=thread_id)

send_message_tool.py 第 566-572 行:

if media_files and not message.strip():
    return {
        "error": (
            f"send_message MEDIA delivery is currently only supported for telegram, discord, matrix, weixin, signal and yuanbao; "
            f"target {platform.value} had only media attachments"
        )
    }

修复建议

参考 Telegram (第 486-503 行) 和 Discord (第 509-524 行) 的实现,修改第 594-595 行为:

# --- Feishu: special handling for media attachments ---
if platform == Platform.FEISHU:
    last_result = None
    for i, chunk in enumerate(chunks):
        is_last = (i == len(chunks) - 1)
        result = await _send_feishu(
            pconfig,
            chat_id,
            chunk,
            media_files=media_files if is_last else [],
            thread_id=thread_id,
        )
        if isinstance(result, dict) and result.get("error"):
            return result
        last_result = result
    return last_result

或简单修复(如果飞书不需要分块处理,直接到最后一个 chunk 传 media_files):

elif platform == Platform.FEISHU:
    # 注意:这里应该传递 media_files,但现在未传递
    result = await _send_feishu(
        pconfig,
        chat_id,
        chunk,
        media_files=media_files,  # <-- 需要添加这行
        thread_id=thread_id
    )

同时需要更新第 563 行的支持平台列表(把 feishu 加上),或删除那条强制错误返回。

验证测试

已在本地验证飞书 API 支持文件发送:

  • ✅ 图片发送:msg_type: image,通过 /im/v1/images 上传
  • ✅ 文件发送:msg_type: file,通过 /im/v1/files 上传
  • ✅ DOCX 文档可正常发送

环境信息

  • Hermes Agent 版本:最新 main 分支
  • 平台:WSL Ubuntu
  • Python 版本:3.11

相关代码

  • _send_feishu 函数定义:send_message_tool.py:1421-1475
  • _send_telegram:参考实现 486-503 行
  • _send_discord:参考实现 509-524 行
  • 飞书适配器:gateway/platforms/feishu.py 已实现 send_image_filesend_document

影响范围:所有通过 send_message 向飞书发送媒体文件的场景 优先级:中(有 workaround 可用)

extent analysis

TL;DR

To fix the issue, pass the media_files parameter to the _send_feishu function when sending media attachments to Feishu.

Guidance

  • Update the _send_feishu function call to include the media_files parameter, as shown in the suggested fix: result = await _send_feishu(pconfig, chat_id, chunk, media_files=media_files, thread_id=thread_id).
  • Alternatively, if Feishu does not require chunking, pass media_files only to the last chunk: result = await _send_feishu(pconfig, chat_id, chunk, media_files=media_files if is_last else [], thread_id=thread_id).
  • Verify the fix by testing media file sending to Feishu using the updated code.
  • Update the supported platforms list on line 563 to include Feishu or remove the error return.

Example

elif platform == Platform.FEISHU:
    result = await _send_feishu(
        pconfig,
        chat_id,
        chunk,
        media_files=media_files,  # <-- Add this line
        thread_id=thread_id
    )

Notes

The suggested fix assumes that the _send_feishu function is correctly implemented to handle media file sending. If issues persist, verify the implementation of _send_feishu and the Feishu adapter in gateway/platforms/feishu.py.

Recommendation

Apply the workaround by passing the media_files parameter to the _send_feishu function, as it is a straightforward fix that should resolve the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix 关于飞书端无法发送图片、DOCX 等附件的BUG [2 comments, 2 participants]