fix(gateway): stream consumer first message drops thread context

Cherry-picked from PR #13077 commits:
- 5500c7d8 fix(gateway): stream consumer first message drops thread context
- e84403b9 test(gateway): add regression tests for stream consumer thread routing

Fixes: Streaming first message drops thread/topic context in Feishu group
topics, Slack threads, Telegram forum topics. Adds initial_reply_to_id
ctor arg to GatewayStreamConsumer, threaded through _send_or_edit and
_send_new_chunk. Also fixes Feishu _send_raw_message fallback path
(reply -> create) to use receive_id_type='thread_id' so the new message
lands in the correct topic instead of the main channel.

Authored by hrygo via PR #13077 (re-attributed from the bot-authored
salvage commit on the original branch).
This commit is contained in:
hrygo 2026-05-10 15:14:38 -07:00 committed by Teknium
parent 6636fecd47
commit ff14666cdc
4 changed files with 221 additions and 15 deletions

View file

@ -13891,6 +13891,7 @@ class GatewayRunner:
chat_id=source.chat_id,
config=_consumer_cfg,
metadata=_thread_metadata,
initial_reply_to_id=event_message_id,
)
except Exception as _sc_err:
logger.debug("Proxy: could not set up stream consumer: %s", _sc_err)
@ -14716,6 +14717,7 @@ class GatewayRunner:
if progress_queue is not None
else None
),
initial_reply_to_id=event_message_id,
)
if _want_stream_deltas:
def _stream_delta_cb(text: str) -> None: