fix(gateway/telegram): route /model picker thread_id through helper#22383
Closed
Matthieu-C wants to merge 1 commit into
Closed
fix(gateway/telegram): route /model picker thread_id through helper#22383Matthieu-C wants to merge 1 commit into
Matthieu-C wants to merge 1 commit into
Conversation
send_model_picker was the last sender in telegram.py that bypassed
_message_thread_id_for_send. In a forum group's General topic the helper
maps the synthetic thread id "1" to None because Telegram's sendMessage
rejects message_thread_id=1 with BadRequest('Message thread not found').
The picker instead passed int("1")=1, the API rejected it, the gateway
swallowed the error, and the user saw the plain-text fallback instead of
the inline-keyboard picker.
Fix: route through _message_thread_id_for_send like every other send
path, plus add the standard 'thread not found' single-retry without
message_thread_id so transient topic-disappearance still delivers the
picker.
Adds regression tests in tests/gateway/test_telegram_model_picker_thread.py
covering General-topic id collapse, real-topic pass-through, thread-not-found
retry, and the no-metadata path.
Collaborator
Collaborator
|
Thanks for catching this — the General-topic mapping ( The parallel code path in the Closing as superseded — thanks for the contribution and for keeping us focused on this bug class! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In any Telegram forum group's General topic,
/modelsilently falls backto a plain-text model list instead of rendering the inline-keyboard picker.
This has been the recurring "after every
hermes update/model breaks again"bug — local post-update patches kept getting wiped because the fix never
landed upstream.
gateway.logconfirms the failure mode:Root Cause
TelegramAdapter.send_model_pickerwas the last sender ingateway/platforms/telegram.pythat bypassed_message_thread_id_for_send.It computed:
The forum General topic surfaces in metadata as
thread_id="1", a syntheticid Hermes uses to scope events to that topic. Telegram's
sendMessagerejects
message_thread_id=1withBadRequest('Message thread not found')— the helper exists precisely to map"1"→Nonefor sends.Every other
_bot.send_*call in this file already routes through it; thepicker was the last hold-out. The exception was caught, a warning was
logged, the picker reported
success=False, andgateway/run.pyfellthrough to its plain-text fallback.
Fix
Route
send_model_picker'sthread_idthrough_message_thread_id_for_sendlike every other send path, and add the standard "thread not found"
single-retry without
message_thread_idso transient topic-disappearancestill delivers the picker (mirrors the contract of
send()and the otherauxiliary methods).
Tests
Adds
tests/gateway/test_telegram_model_picker_thread.pywith 4 cases:metadata={"thread_id": "1"}must send withmessage_thread_id=None. This is the regression guard for the original bug."17585"must reach Telegram as17585.retry once without
message_thread_idand still succeed.Audit
grep -n "message_thread_id=int" gateway/platforms/telegram.pynow returns asingle hit at line 729 —
edit_forum_topic, whereint(thread_id)iscorrect (renaming a topic genuinely needs the topic id, including
1).Every other
_bot.send_*call routes through_message_thread_id_for_send,matching the invariant documented in
software-development/debugging-hermes-tui-commands/references/gateway-interactive-pickers.md.