hermes - 💡(How to fix) Fix Feishu 文档工具在私聊/DM 场景下不可用(Feishu client not available) [3 pull requests]

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…

Fix Action

Fixed

Code Example

client = get_client()
  if client is None:
      return tool_error("Feishu client not available (not in a Feishu comment context)")

---

from tools import feishu_doc_tool, feishu_drive_tool
feishu_doc_tool.set_client(client)
feishu_drive_tool.set_client(client)
RAW_BUFFERClick to expand / collapse

问题描述

feishu_doc_readfeishu_drive_list_commentsfeishu_drive_reply_commentfeishu_drive_add_comment 等飞书相关工具在私聊/DM 场景下全部返回 "Feishu client not available""Feishu client not available (not in a Feishu comment context)",无法读取飞书文档内容或操作文档评论。

根因分析

tools/feishu_doc_tool.pytools/feishu_drive_tool.py 中的工具依赖 thread-local 的 lark_oapi client,该 client 仅在飞书文档评论场景gateway/platforms/feishu_comment.py)通过 set_client() 注入。

在私聊/DM 场景下,没有任何代码调用 set_client(),因此 get_client() 返回 None,所有工具立即报错退出。

关键代码

  • tools/feishu_doc_tool.py 第 74-76 行:
    client = get_client()
    if client is None:
        return tool_error("Feishu client not available (not in a Feishu comment context)")
  • tools/feishu_drive_tool.py 第 134-136 行(以及其他所有 handler 相同逻辑)
  • tools/feishu_doc_tool.py / tools/feishu_drive_tool.py 中的 set_client() 函数(第 19-21 行)仅在 gateway/platforms/feishu_comment.py 中被调用

建议修复方案

gateway/platforms/feishu.py 初始化时,将 lark_oapi client 也注入到这些工具的 thread-local 中,使 DM 场景也能调用飞书文档 API。

具体来说,在 Feishu 平台 adapter 初始化完成(获取 tenant_access_token 后)时,调用:

from tools import feishu_doc_tool, feishu_drive_tool
feishu_doc_tool.set_client(client)
feishu_drive_tool.set_client(client)

涉及文件

  • tools/feishu_doc_tool.pyset_client() / get_client() 机制定义
  • tools/feishu_drive_tool.py — 同上
  • gateway/platforms/feishu.py — 需要在初始化时注入 client
  • gateway/platforms/feishu_comment.py — 当前唯一注入 client 的地方

环境

  • Hermes Agent 版本:v2026.5.16
  • 场景:飞书私聊 DM(非文档评论场景)

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 Feishu 文档工具在私聊/DM 场景下不可用(Feishu client not available) [3 pull requests]