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

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
This commit is contained in:
argo-macbook 2026-04-17 13:51:25 +08:00
parent 816e3e3774
commit 8370c75c93

View file

@ -3417,15 +3417,17 @@ class FeishuAdapter(BasePlatformAdapter):
reply_to: Optional[str],
metadata: Optional[Dict[str, Any]],
) -> Any:
reply_in_thread = bool((metadata or {}).get("thread_id"))
if reply_to:
thread_id = (metadata or {}).get("thread_id")
reply_in_thread = bool(thread_id)
effective_reply_to = reply_to or (thread_id if reply_in_thread else None)
if effective_reply_to:
body = self._build_reply_message_body(
content=payload,
msg_type=msg_type,
reply_in_thread=reply_in_thread,
uuid_value=str(uuid.uuid4()),
)
request = self._build_reply_message_request(reply_to, body)
request = self._build_reply_message_request(effective_reply_to, body)
return await asyncio.to_thread(self._client.im.v1.message.reply, request)
body = self._build_create_message_body(