fix(feishu): ignore thread_id in DM quoted replies to prevent isolated sessions - #44083
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(feishu): ignore thread_id in DM quoted replies to prevent isolated sessions#44083liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…d sessions When a user sends a quoted reply (引用回复) in a Feishu/Lark DM, the Lark SDK populates `message.thread_id` (or `message.root_id`) with the parent message ID. This thread_id then flows into `build_session_key()`, creating an isolated session (e.g. `feishu:dm:oc_xxx:om_yyy` instead of `feishu:dm:oc_xxx`), which causes the agent to lose all conversation context. Feishu DMs do not support real threads — only group chats do. The fix clears thread_id for p2p (DM) chat_type in `_process_inbound_message`.
Collaborator
Contributor
Author
|
Thanks for the flag @alt-glitch. Confirmed — #36233 is a more comprehensive fix (+342 lines covering root_id/thread_id distinction across multiple code paths). Closing in favor of #36233. |
This was referenced Jun 11, 2026
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes an issue where Feishu/Lark DM quoted replies (引用回复) create isolated sessions, causing the agent to lose all conversation context. When a user quotes/replies to a message in a DM, the Lark SDK populates
thread_id/root_id, which then flows into the session key and creates a brand new empty session instead of continuing the existing DM conversation.Related Issue
Fixes #44028
Type of Change
Changes Made
gateway/platforms/feishu.py: In_process_inbound_message, clearthread_idwhenchat_type == "p2p"(DM), since Feishu DMs do not support real threads — only group chats do. (+4 lines)tests/gateway/test_feishu.py: Add two regression tests —test_p2p_quoted_reply_ignores_thread_idverifies DM quoted replies getthread_id=None, andtest_group_quoted_reply_preserves_thread_idverifies group thread routing is unaffected. (+89 lines)How to Test
python -m pytest tests/gateway/test_feishu.py -k "test_p2p_quoted_reply_ignores_thread_id or test_group_quoted_reply_preserves_thread_id" -v— both new tests should passpython -m pytest tests/gateway/test_feishu.py -q— all 162 tests pass, 45 skipped (no regressions)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
_process_inbound_messageingateway/platforms/feishu.py(line 3098);build_source→build_session_keyflow for DM session key constructionchat_type == "p2p"guard pattern used elsewhere in feishu.py (e.g., line 3891)