Skip to content

The agent that grows with you

fix(stream): thread only full fallback resends

kshitijk4poorf026de7d4daa
diff --git a/gateway/stream_consumer_fallback.py b/gateway/stream_consumer_fallback.py
index 21df1e53305..44ca80fae5d 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