Skip to content

fix(feishu): remove root_id fallback from thread_id resolution - #23282

Closed
KhanCold wants to merge 1 commit into
NousResearch:mainfrom
KhanCold:fix/feishu-root-id-session-routing
Closed

fix(feishu): remove root_id fallback from thread_id resolution#23282
KhanCold wants to merge 1 commit into
NousResearch:mainfrom
KhanCold:fix/feishu-root-id-session-routing

Conversation

@KhanCold

Copy link
Copy Markdown

Problem

In the Feishu adapter, root_id was incorrectly used as a fallback for thread_id:

thread_id = getattr(message, "thread_id", None) or getattr(message, "root_id", None) or None

This is wrong because root_id is the first message in a thread, not a thread identifier.

The result: when a user sends a quoted reply in a P2P DM, Hermes would open a spurious thread session (since root_id is present) instead of continuing the normal DM conversation. This breaks reply threading in private chats.

Fix

Remove the root_id fallback from thread_id resolution. root_id remains legitimately used in reply_to_message_id (it's the root message of the thread being replied to), but it must not leak into session routing.

thread_id = getattr(message, "thread_id", None) or None

Regression Test

Added test_p2p_quote_reply_does_not_use_root_id_as_thread_id in tests/gateway/test_feishu.py that verifies:

  • A P2P message with root_id="om_root" and thread_id=None produces event.source.thread_id is None
  • reply_to_message_id still correctly captures the parent message

Context

This addresses the issue raised in review comment on #22969 by @sicnuyudidi.

root_id is the first message in a thread, not a thread identifier.
Using it as fallback for thread_id caused P2P quoted replies to be
incorrectly routed to a spurious thread session instead of the DM.

- Remove  from thread_id resolution
- Keep root_id in reply_to_message_id (legitimate use)
- Add regression test ensuring quoted replies in P2P have thread_id=None

Refs: NousResearch#22969 (review comment)
@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 May 10, 2026
@KhanCold KhanCold closed this May 10, 2026
@KhanCold

Copy link
Copy Markdown
Author

Closing this PR as the fix is already being addressed by #20562 (`fix(feishu): avoid threading regular replies`) which covers the same root_id/thread_id issue with regression tests. Thanks for the contribution!

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