Skip to content

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

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

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.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the Feishu topic-thread routing failure. This is already implemented on current main through a broader fix.

  • Automated hermes-sweeper review verified commit 441ef75d157d6308a9f14d42a7b0ec8566866ef8 (fix(feishu): keep topic replies in threads), shipped in v2026.5.7.
  • plugins/platforms/feishu/adapter.py:4609 uses reply_to_message_id as the threaded reply anchor when available.
  • plugins/platforms/feishu/adapter.py:4623 routes anchorless topic messages with receive_id=thread_id, preventing a top-level fallback.
  • tests/gateway/test_feishu.py:2080 covers metadata-driven threaded reply routing.

The original gateway/platforms/feishu.py path has since been migrated to the bundled Feishu plugin, and main now provides the requested behavior.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 12, 2026
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 sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants