Skip to content

fix(feishu): keep quoted DMs out of topic routing - #82645

Closed
JingZed wants to merge 1 commit into
NousResearch:mainfrom
JingZed:fix/feishu-quoted-reply-visibility-upstream
Closed

JingZed wants to merge 1 commit into
NousResearch:mainfrom
JingZed:fix/feishu-quoted-reply-visibility-upstream

Conversation

@JingZed

@JingZed JingZed commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Fix Feishu quoted replies in direct messages being routed as topic/thread messages and disappearing from the main conversation.

Feishu sets root_id on a quoted/replied DM to identify the root of the reply chain. The adapter previously promoted that value to source.thread_id whenever a real message.thread_id was absent. Downstream reply routing then treated an ordinary DM quote chain as a topic/thread and anchored the bot response to the quoted message instead of the new triggering message.

Root cause

thread_id = message.thread_id or message.root_id

In a p2p chat, root_id is reply-chain context, not topic routing metadata. It already remains available through reply_to_message_id; it should not also become source.thread_id.

Fix

  • In Feishu p2p chats, populate normalized source.thread_id only from an actual message.thread_id.
  • Preserve the existing root_id fallback for non-p2p chats, because Feishu group topics may use it as routing context.
  • Preserve root_id as the reply_to_message_id fallback in all chats.
  • Add regression coverage that verifies:
    • a quoted DM has no normalized thread when message.thread_id is absent;
    • the quote root remains available as reply context;
    • the outbound reply anchor resolves to the current triggering message;
    • group-topic root_id routing remains unchanged.

Reproduction

On current main, the DM regression test fails with:

AssertionError: 'om_quoted_root' is not None

The normalized DM event incorrectly receives source.thread_id = root_id.

Test plan

  • Verified the new DM regression test fails against the old adapter behavior.
  • scripts/run_tests.sh tests/gateway/test_feishu.py -q
    • 78 passed, 0 failed
  • ruff check plugins/platforms/feishu/adapter.py tests/gateway/test_feishu.py
  • Python bytecode compilation for both changed files
  • git diff --check
  • Live Feishu validation: quoting another message now produces a visible bot reply in the main DM conversation.

@JingZed
JingZed force-pushed the fix/feishu-quoted-reply-visibility-upstream branch from fbad272 to c52a614 Compare August 9, 2026 18:30
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins platform/feishu Feishu / Lark adapter P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Aug 9, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Duplicate of #30164: both preserve root_id for non-p2p routing while preventing a Feishu DM quote root from becoming thread metadata.

@JingZed

JingZed commented Aug 9, 2026

Copy link
Copy Markdown
Author

Confirmed — thanks for the pointer. I compared the production change and regression coverage directly: #30164 already implements the same p2p-only root_id guard while preserving non-p2p topic routing and reply context. Closing this PR as a duplicate in favor of #30164.

@JingZed

JingZed commented Aug 9, 2026

Copy link
Copy Markdown
Author

Closing as duplicate of #30164.

@JingZed JingZed closed this Aug 9, 2026
@JingZed
JingZed deleted the fix/feishu-quoted-reply-visibility-upstream branch August 9, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants