Skip to content

fix: use _message_thread_id_for_send in send_model_picker#18612

Closed
chiyema wants to merge 1 commit into
NousResearch:mainfrom
chiyema:fix/telegram-thread-not-found-retry
Closed

fix: use _message_thread_id_for_send in send_model_picker#18612
chiyema wants to merge 1 commit into
NousResearch:mainfrom
chiyema:fix/telegram-thread-not-found-retry

Conversation

@chiyema

@chiyema chiyema commented May 2, 2026

Copy link
Copy Markdown

Problem

send_model_picker in the Telegram adapter uses raw int(thread_id) if thread_id else None for message_thread_id, bypassing the _message_thread_id_for_send helper. This helper maps the General topic (thread_id="1") to None, which is required because the Telegram Bot API rejects message_thread_id=1 with Message thread not found in forum groups.

As a result, /model in the General topic of a forum group fails to show the interactive inline keyboard picker, falling back to the plain text list.

Fix

One-line change: replace the raw int() conversion with the existing _message_thread_id_for_send() helper, consistent with all other send methods in the adapter.

Testing

Verified the issue in gateway logs:

send_model_picker failed: Message thread not found

All other send methods (send_message, send_voice, send_image_file, etc.) already use the helper correctly — send_model_picker was the only one still using raw conversion.

send_model_picker used raw int(thread_id) conversion, bypassing the
_message_thread_id_for_send helper that maps the General topic
(thread_id=1) to None. This caused 'Message thread not found' errors
from the Telegram API in forum groups when /model was used in the
General topic, falling back to the text list instead of showing
interactive inline keyboard buttons.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of PR #12873 — identical one-line fix for send_model_picker bypassing _message_thread_id_for_send(). Also fixes #12839.

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Thanks for catching this — the General-topic mapping (message_thread_id="1"None) you proposed for send_model_picker is now on main. It landed via #22410 (salvage of @leehack's #22053 telegram DM topic fix), which routed send_model_picker through _thread_kwargs_for_send — a strict superset of the _message_thread_id_for_send mapping you proposed. That helper now handles both forum General topics (your case) AND Hermes-created DM topic lanes that #22053 was originally about.

The parallel code path in the send_message tool's standalone _send_telegram helper had the same bug — fixed in #22423 just now (Fixes #22267).

Closing as superseded — thanks for the contribution and for keeping us focused on this bug class!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants