fix(cron): route Telegram forum topics via message_thread_id, support channel DM topics (#52060) - #58165
Merged
kshitijk4poor merged 1 commit intoJul 4, 2026
Conversation
kshitijk4poor
force-pushed
the
fix/52060-cron-dm-topic-routing
branch
from
July 4, 2026 08:58
ce5ada7 to
6ab8eab
Compare
…ry time (NousResearch#52060) The NousResearch#22773 heuristic classified any telegram:<positive_chat_id>:<numeric_thread_id> cron target as a Bot API channel Direct-Messages topic and routed it via direct_messages_topic_id, which nulls message_thread_id. A normal forum-style topic inside a private chat has the identical shape, so every such cron delivery landed in General instead of the target thread (NousResearch#52060). It also means the only way to address a genuine channel DM topic was this same ambiguous guess. Disambiguate with the real runtime signal instead: probe the live adapter's get_chat_info once and route via direct_messages_topic_id only when the chat is actually a channel; everything else (private forum topic, forum supergroup, group) and any probe failure fall back to message_thread_id — parity with 0.16.0 and with live reply routing. This fixes forum-topic delivery AND makes genuine channel DM-topic cron delivery work correctly.
kshitijk4poor
force-pushed
the
fix/52060-cron-dm-topic-routing
branch
from
July 4, 2026 09:03
6ab8eab to
fc31f14
Compare
kshitijk4poor
enabled auto-merge
July 4, 2026 09:03
Collaborator
Related: this is the active resubmission of the closed #52079 (both fix #52060). Competing OPEN fix: #55270 removes the |
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…on-dm-topic-routing fix(cron): route Telegram forum topics via message_thread_id, support channel DM topics (NousResearch#52060)
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…on-dm-topic-routing fix(cron): route Telegram forum topics via message_thread_id, support channel DM topics (NousResearch#52060)
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…on-dm-topic-routing fix(cron): route Telegram forum topics via message_thread_id, support channel DM topics (NousResearch#52060)
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…on-dm-topic-routing fix(cron): route Telegram forum topics via message_thread_id, support channel DM topics (NousResearch#52060)
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.
Summary
Cron deliveries to a Telegram topic now land in the right thread — both ordinary forum-style topics in a private chat and genuine Bot API channel Direct-Messages topics.
Root cause: the
#22773heuristic classified anytelegram:<positive_chat_id>:<numeric_thread_id>cron target as a Bot API channel Direct-Messages topic and routed it viadirect_messages_topic_id, which makes the adapter nullmessage_thread_id. A normal forum-style topic inside a private chat has the identical shape, so every such cron delivery landed in General instead of the target thread (#52060). It also meant the only way to address a genuine channel DM topic was this same ambiguous guess.Changes
cron/scheduler.py: new_is_channel_dm_topic()helper replaces the shape-based heuristic. It probes the live adapter'sget_chat_info()once at delivery time and routes viadirect_messages_topic_idonly when the chat is actually achannel; everything else (private-chat forum topic, forum supergroup, group) and any probe error/timeout/Nonefall back tomessage_thread_id— parity with 0.16.0 and with live reply routing.thread_idis placed inroute_metadatadeliberately so the anchorless cron send bypasses the DeliveryRouter's private-chat reply-anchor requirement.tests/cron/test_scheduler.py: behavior-contract tests for forum-topic →message_thread_id, channel-DM-topic →direct_messages_topic_id(text + media each), plus two fail-safe paths (probe raises, probe returnsNone).Validation
maindirect_messages_topic_id— the bug)message_thread_id)message_thread_id, channel→direct_messages_topic_id, raise/None/no-probe→fail-safe_deliver_resultE2Eadapter.sendin both branchesCredit
Thanks to @Tranquil-Flow (#52079) for reporting and diagnosing #52060. This takes their idea — gate the DM-topic route rather than infer it from chat-id sign — and grounds it in a real runtime signal (
get_chat_infochat type) instead of an origin key that no code path produces, so genuine channel DM-topic cron delivery works too.Closes #52060