Skip to content

fix(outbound): keep reply_to on every chunk when threading#6

Open
Ydz0616 wants to merge 1 commit into
larksuite:mainfrom
Ydz0616:fix/thread-reply-keeps-all-chunks
Open

fix(outbound): keep reply_to on every chunk when threading#6
Ydz0616 wants to merge 1 commit into
larksuite:mainfrom
Ydz0616:fix/thread-reply-keeps-all-chunks

Conversation

@Ydz0616

@Ydz0616 Ydz0616 commented Jul 8, 2026

Copy link
Copy Markdown

Problem

In a Lark thread/topic chat, the tail of a long threaded reply leaks out of the thread into the main chat.

OutboundSender._send_text splits a message over text_chunk_limit into multiple bodies but applies reply_to only to the first chunk (reply_to if idx == 0 else None). The comment assumes "fresh messages render in the original chat" — true for a normal reply, but in a thread/topic chat a message sent without a reply parent renders in the main chat, not the thread. So chunks after the first leak out of the topic.

Fix

Keep reply_to on every chunk when reply_in_thread is set:

effective_reply_to = reply_to if (idx == 0 or reply_in_thread) else None

Each chunk replies to the same root with reply_in_thread=True, so all pieces stay in the thread. Non-thread replies are unchanged (still first-chunk-only quote).

Reproduction

Topic-mode group, send a >3500-char markdown message with SendOpts(reply_to=<root>, reply_in_thread=True):

  • before: first chunk threaded, remaining chunks in the main chat;
  • after: all chunks in the thread.

Closes #5.

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) <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long threaded reply leaks out of a topic/thread chat: reply_to dropped on chunks after the first

2 participants