hermes - 💡(How to fix) Fix [Bug] 飞书跨 agent 主动发送时消息丢失 thread 上下文

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…

Code Example

elif getattr(source, "platform", None) == Platform.FEISHU and thread_id:
    anchor = reply_to_message_id or getattr(source, "message_id", None)
    if anchor is not None:
        metadata["reply_to_message_id"] = str(anchor)

---

if not thread_id:
    from gateway.session_context import get_session_env
    session_thread = get_session_env("HERMES_SESSION_THREAD_ID", "").strip()
    if session_thread:
        thread_id = session_thread
RAW_BUFFERClick to expand / collapse

环境

  • Hermes-Agent + 飞书插件
  • 飞书群聊 topic/thread 模式

问题

Agent 在飞书话题中被 @ 触发后,主动向群内发送消息(非 reply)时,消息落在群主时间线而非当前话题内。仅 reply 场景下消息正确进入话题。

根因

两条发送路径都会丢失 thread 上下文:

路径 1:agent 直接开口

_thread_metadata_for_source 对飞书只传了 thread_id,未传 reply_to_message_id_send_raw_messageeffective_reply_to 为 None → 走 create API 发到主群。

路径 2:send_message 工具

channel directory 中同时存在 base entry(无 thread_id)和 thread entry(有 thread_id)。名称解析时精确匹配优先命中 base entry → thread_id 丢失。

修复建议

路径 1

_thread_metadata_for_source 在飞书场景补 reply_to_message_id

elif getattr(source, "platform", None) == Platform.FEISHU and thread_id:
    anchor = reply_to_message_id or getattr(source, "message_id", None)
    if anchor is not None:
        metadata["reply_to_message_id"] = str(anchor)

路径 2

send_message_tool.py 在 name resolution 后,若 resolved 结果无 thread_id 但 session env 有,则追加:

if not thread_id:
    from gateway.session_context import get_session_env
    session_thread = get_session_env("HERMES_SESSION_THREAD_ID", "").strip()
    if session_thread:
        thread_id = session_thread

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 [Bug] 飞书跨 agent 主动发送时消息丢失 thread 上下文