fix(stream): thread only full fallback resends

The contributor's hunk passed reply_to=_initial_reply_to_id on every
fallback chunk, which also re-threaded tail continuations on every
platform. On main this chunk loop sends with no reply_to at all, so a
full resend (Feishu post vs cleaned-text prefix mismatch, #103068) lands
unthreaded next to the preview it replaces.

Thread only the full-resend case (continuation == final_text), and only
its first chunk. Tail continuations keep main's unthreaded delivery.

Co-authored-by: HanYunChenLuo <23613397+HanYunChenLuo@users.noreply.github.com>
Co-authored-by: Bartok9 <259807879+Bartok9@users.noreply.github.com>
Co-authored-by: huangyoje <25878791+huangyoje@users.noreply.github.com>
This commit is contained in:
kshitijk4poor
2026-09-24 16:47:32 +05:30
committed by kshitij
parent 11d5fb153d
commit f026de7d4d

View File

@@ -121,9 +121,12 @@ class StreamFallbackMixin:
last_message_id: Optional[str] = None
last_successful_chunk = ""
sent_any_chunk = False
# Thread only a FULL resend (it replaces the preview); a tail continuation
# keeps its existing unthreaded delivery on every platform.
anchor = self._initial_reply_to_id if continuation == final_text else None
for chunk in chunks:
result = await self._send_with_flood_retry(
content=chunk, reply_to=self._initial_reply_to_id,
content=chunk, reply_to=None if sent_any_chunk else anchor,
retry_log="Flood control on fallback send, retrying in %.1fs")
if not result or not result.success:
# Partial continuation landed: do NOT set _final_response_sent (the