From 4df9fa5bc9eb5da29a6710ba56078da635ec854a Mon Sep 17 00:00:00 2001 From: Ydz0616 Date: Tue, 7 Jul 2026 17:50:15 -0700 Subject: [PATCH] fix(outbound): keep reply_to on every chunk when threading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A message longer than text_chunk_limit is split into multiple bodies, but reply_to is applied only to the first chunk (reply_to if idx == 0 else None), so later chunks are sent as fresh create_message calls. For a normal reply that is fine, but in a THREAD/topic chat a message without a reply parent renders in the main chat instead of the thread — so the tail of a long threaded reply leaks out of the topic. Keep reply_to on every chunk when reply_in_thread is set. Co-Authored-By: Claude Opus 4.8 (1M context) --- lark_channel/channel/outbound/sender.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lark_channel/channel/outbound/sender.py b/lark_channel/channel/outbound/sender.py index f4ef5ea..96a2eef 100644 --- a/lark_channel/channel/outbound/sender.py +++ b/lark_channel/channel/outbound/sender.py @@ -385,9 +385,11 @@ async def send( last_result: SendResult = SendResult.fail(SendError(code=FeishuChannelErrorCode.UNKNOWN, retryable=False)) for idx, body in enumerate(body_list): req_uuid = uuid_ if (idx == 0 and uuid_) else str(uuid.uuid4()) - # Only apply `reply_to` to the first chunk; subsequent chunks are - # fresh messages so they all render in the original chat. - effective_reply_to = reply_to if idx == 0 else None + # Apply `reply_to` to the first chunk, and to every chunk when threading. + # A fresh (non-reply) message renders in the origin chat for a normal reply, + # but in a THREAD/topic chat it drops out of the thread into the main chat — + # so later chunks must keep the reply to stay in the thread. + effective_reply_to = reply_to if (idx == 0 or reply_in_thread) else None result = await self._send_one_with_fallback( body=body, receive_id=receive_id,