From f026de7d4daa959394f38d63fdad5fa55488966e Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 24 Sep 2026 16:47:32 +0530 Subject: [PATCH] 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> --- gateway/stream_consumer_fallback.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gateway/stream_consumer_fallback.py b/gateway/stream_consumer_fallback.py index 21df1e5330..44ca80fae5 100644 --- a/gateway/stream_consumer_fallback.py +++ b/gateway/stream_consumer_fallback.py @@ -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