feat(feishu): add thread-scoped session isolation for group chats

Thread replies (messages with root_id != message_id) in group chats
now get their own session key: feishu:{chat_id}:{root_id}. This
means each Feishu thread has an independent conversation context.

Top-level group messages and all private chat messages keep the
default session key (no override), consistent with Telegram and
Slack channel behavior.

Co-authored-by: shenchengtsi <228445050+shenchengtsi@users.noreply.github.com>
This commit is contained in:
chengyongru
2026-04-26 16:09:31 +08:00
committed by Xubin Ren
co-authored by shenchengtsi
parent fd3d7ea752
commit 13bb31c789
2 changed files with 103 additions and 2 deletions
+10
View File
@@ -1624,6 +1624,15 @@ class FeishuChannel(BaseChannel):
if not content and not media_paths:
return
# Build topic-scoped session key for conversation isolation.
# Group chat: thread replies (root_id != message_id) get a scoped
# session so each Feishu thread has its own conversation context.
# Private chat: no override — same behavior as Telegram/Slack.
if chat_type == "group" and root_id and root_id != message_id:
session_key = f"feishu:{chat_id}:{root_id}"
else:
session_key = None
# Forward to message bus
reply_to = chat_id if chat_type == "group" else sender_id
await self._handle_message(
@@ -1640,6 +1649,7 @@ class FeishuChannel(BaseChannel):
"root_id": root_id,
"thread_id": thread_id,
},
session_key=session_key,
)
except Exception as e: