fix: forward thread_id metadata for Telegram forum topic routing - #656
fix: forward thread_id metadata for Telegram forum topic routing#656Bitstreamono wants to merge 1 commit into
Conversation
When using Telegram forum topics, incoming messages correctly capture
message_thread_id as event.source.thread_id, but responses are sent
without metadata={"thread_id": ...}, causing all replies to land in
"General" instead of the originating topic thread.
Changes:
- base.py: Build _response_metadata from event.source.thread_id and
pass to all send calls (text, images, voice, video, documents).
Add metadata kwarg to all media method signatures. Thread metadata
through _keep_typing and send_typing.
- telegram.py: Accept metadata in send_voice, send_image,
send_animation, send_typing. Extract thread_id and pass as
message_thread_id to Bot API calls.
- run.py: Build _progress_metadata from source.thread_id and pass
to progress/streaming adapter.send() calls.
- discord/slack/whatsapp/homeassistant: Update send_typing signature
for compatibility.
3ff7e25 to
0537822
Compare
Replies in Telegram forum topics (supergroups with topics) now land in the correct topic thread instead of 'General'. - base.py: build thread_id metadata from event.source, pass to all send/media calls; add metadata param to send_typing, send_image, send_animation, send_voice, send_video, send_document, send_image_file, _keep_typing - telegram.py: extract thread_id from metadata and pass as message_thread_id to all Bot API calls (send_photo, send_voice, send_audio, send_animation, send_chat_action) - run.py: pass thread_id metadata to progress/streaming send calls - discord/slack/whatsapp/homeassistant: update send_typing signature Based on the fix proposed by @Bitstreamono in PR #656.
…tures Part 2 of thread_id forum topic fix: add metadata param to send_voice, send_image, send_animation, send_typing in Telegram adapter and pass message_thread_id to all Bot API calls. Update send_typing signature in Discord, Slack, WhatsApp, HomeAssistant for compatibility. Based on the fix proposed by @Bitstreamono in PR #656.
|
Thanks for identifying this bug @Bitstreamono — the thread_id forwarding fix is correct and needed. We've applied the metadata forwarding changes in commits a630ca1 and 928bb16, crediting you in both commit messages. However, we couldn't merge the PR directly because it also removed two important features:
The thread_id fix itself is great work — just for future PRs, try to keep changes focused on the fix without removing unrelated code. Thanks again! |
Replies in Telegram forum topics (supergroups with topics) now land in the correct topic thread instead of 'General'. - base.py: build thread_id metadata from event.source, pass to all send/media calls; add metadata param to send_typing, send_image, send_animation, send_voice, send_video, send_document, send_image_file, _keep_typing - telegram.py: extract thread_id from metadata and pass as message_thread_id to all Bot API calls (send_photo, send_voice, send_audio, send_animation, send_chat_action) - run.py: pass thread_id metadata to progress/streaming send calls - discord/slack/whatsapp/homeassistant: update send_typing signature Based on the fix proposed by @Bitstreamono in PR NousResearch#656.
…tures Part 2 of thread_id forum topic fix: add metadata param to send_voice, send_image, send_animation, send_typing in Telegram adapter and pass message_thread_id to all Bot API calls. Update send_typing signature in Discord, Slack, WhatsApp, HomeAssistant for compatibility. Based on the fix proposed by @Bitstreamono in PR NousResearch#656.
Replies in Telegram forum topics (supergroups with topics) now land in the correct topic thread instead of 'General'. - base.py: build thread_id metadata from event.source, pass to all send/media calls; add metadata param to send_typing, send_image, send_animation, send_voice, send_video, send_document, send_image_file, _keep_typing - telegram.py: extract thread_id from metadata and pass as message_thread_id to all Bot API calls (send_photo, send_voice, send_audio, send_animation, send_chat_action) - run.py: pass thread_id metadata to progress/streaming send calls - discord/slack/whatsapp/homeassistant: update send_typing signature Based on the fix proposed by @Bitstreamono in PR NousResearch#656.
…tures Part 2 of thread_id forum topic fix: add metadata param to send_voice, send_image, send_animation, send_typing in Telegram adapter and pass message_thread_id to all Bot API calls. Update send_typing signature in Discord, Slack, WhatsApp, HomeAssistant for compatibility. Based on the fix proposed by @Bitstreamono in PR NousResearch#656.
Replies in Telegram forum topics (supergroups with topics) now land in the correct topic thread instead of 'General'. - base.py: build thread_id metadata from event.source, pass to all send/media calls; add metadata param to send_typing, send_image, send_animation, send_voice, send_video, send_document, send_image_file, _keep_typing - telegram.py: extract thread_id from metadata and pass as message_thread_id to all Bot API calls (send_photo, send_voice, send_audio, send_animation, send_chat_action) - run.py: pass thread_id metadata to progress/streaming send calls - discord/slack/whatsapp/homeassistant: update send_typing signature Based on the fix proposed by @Bitstreamono in PR NousResearch#656.
…tures Part 2 of thread_id forum topic fix: add metadata param to send_voice, send_image, send_animation, send_typing in Telegram adapter and pass message_thread_id to all Bot API calls. Update send_typing signature in Discord, Slack, WhatsApp, HomeAssistant for compatibility. Based on the fix proposed by @Bitstreamono in PR NousResearch#656.
Summary
When using Telegram forum topics (supergroups with topics enabled), incoming messages correctly capture
message_thread_idasevent.source.thread_id, but responses are sent withoutmetadata={"thread_id": ...}, causing all replies to land in "General" instead of the originating topic thread.Root Cause
_process_message_background()inbase.pynever constructs metadata from the event source when callingself.send()and media methods. TheTelegramAdapter.send()method already supportsmessage_thread_idvia metadata — it's just never called with it.Additionally, all media methods (
send_voice,send_image,send_animation) andsend_typing/send_chat_actionin the Telegram adapter are missingmessage_thread_identirely.Changes
gateway/platforms/base.py_response_metadatafromevent.source.thread_idin_process_message_background()metadatakwarg to base signatures:send_image,send_animation,send_voice,send_video,send_document,send_image_file,send_typing_keep_typinggateway/platforms/telegram.pymetadatainsend_voice,send_image,send_animation,send_typingthread_idand pass asmessage_thread_idto all Bot API callsgateway/run.py_progress_metadatafromsource.thread_idin_run_agent()adapter.send()callsgateway/platforms/{discord,slack,whatsapp,homeassistant}.pysend_typingsignature for compatibility (metadata=None)Impact