Skip to content

fix(feishu): use thread_id as reply target when reply_to is empty#11433

Open
youttiao wants to merge 1 commit into
NousResearch:mainfrom
youttiao:fix/feishu-thread-reply
Open

fix(feishu): use thread_id as reply target when reply_to is empty#11433
youttiao wants to merge 1 commit into
NousResearch:mainfrom
youttiao:fix/feishu-thread-reply

Conversation

@youttiao

Copy link
Copy Markdown

Summary

Fixes Feishu topic group (话题群) replies falling through to top-level messages instead of staying within the thread.

Problem: In Feishu topic groups, messages within a thread carry a thread_id in metadata but the reply_to parameter can be None. The existing code only checked reply_to to decide whether to use the reply API, so thread messages with no reply_to would silently fall back to create_message — posting a new top-level message instead of replying in-thread.

Fix: Extract thread_id from metadata and use it as a fallback when reply_to is absent. This ensures the reply API is called with the correct message target, keeping responses within the thread context.

Changes

  • gateway/platforms/feishu.py: 3 lines changed in _send_single_message
    • Extract thread_id before the reply decision
    • Compute effective_reply_to = reply_to or thread_id
    • Use effective_reply_to for both the guard condition and the reply request

Testing

Tested in production with a Feishu bot deployed in topic groups (话题群). Before the fix, bot responses appeared as new top-level messages. After the fix, responses correctly appear within the originating thread.

Made with Cursor

In Feishu topic groups (话题群), messages within a thread have a
thread_id but the reply_to field can be empty. The original code
only used reply_to for the reply API call, causing replies to
fall back to creating new top-level messages instead of replying
within the thread.

Now falls back to thread_id when reply_to is absent, ensuring
responses stay in the correct thread context.

Made-with: Cursor
nickdlkk added a commit to nickdlkk/hermes-agent that referenced this pull request Apr 21, 2026
PR NousResearch#11433 introduced a regression: effective_reply_to = reply_to or thread_id
causes message.reply to be called with thread_id as the target message_id.
Feishu's reply API requires an actual message_id, not a thread_id,
so this causes 'message not found' errors and messages are created
as new top-level messages instead of within the topic.

Fix:
- When reply_to is present: use reply API with reply_to as message_id,
  pass thread_id as a separate query parameter
- When reply_to is absent: use create API with topic_id=thread_id
  to place the message inside the correct topic
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter labels Apr 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #8656 and #13077 — same root cause: Feishu topic group thread_id not used as fallback when reply_to is absent, causing replies to land as top-level messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants