Skip to content

fix: route Telegram DM topic deliveries correctly#27107

Closed
stepanov1975 wants to merge 6 commits into
NousResearch:mainfrom
stepanov1975:fix/telegram-dm-topic-delivery
Closed

fix: route Telegram DM topic deliveries correctly#27107
stepanov1975 wants to merge 6 commits into
NousResearch:mainfrom
stepanov1975:fix/telegram-dm-topic-delivery

Conversation

@stepanov1975

@stepanov1975 stepanov1975 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Route Telegram private DM topic deliveries through the correct mode instead of treating every private topic as a Direct Messages topic.
  • Require anchors for legacy/ambiguous numeric private DM topic sends, while preserving explicit telegram_direct_messages_topic_id support for true Bot API Direct Messages topics.
  • Add named private DM topic creation via createForumTopic, persistence of returned message_thread_id, and stale-thread refresh/retry behavior.
  • Isolate API server environment variables in gateway tests so local installs do not alter test defaults.

Related Issues

Test Plan

  • python -m pytest -q tests/gateway/test_delivery.py tests/gateway/test_telegram_thread_fallback.py tests/gateway/test_dm_topics.py -o 'addopts='
  • python -m pytest -q tests/gateway
  • Live verification via Hermes DeliveryRouter to configured Telegram DM topics: Personal, Test, Debug, Installation, and smoke topic all returned successful Telegram message ids.

@cardtest15-coder

This comment was marked as spam.

@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 16, 2026
teknium1 added a commit that referenced this pull request May 25, 2026
…quired guard

Salvage follow-up. The new private-DM-topic fail-loud contract from
PR #27107 hits 'requires a reply anchor' when reply_to_mode='off' is
configured, even though commit 21a15b6 (PR #23994) verified that
message_thread_id alone routes correctly on python-telegram-bot's
reference client when the user has explicitly opted out of quote
bubbles. Carve out the explicit opt-in path so users on reply_to_mode
'off' aren't regressed — the new guard now only applies to callers
that didn't ask for the anchor to be suppressed.
@teknium1

Copy link
Copy Markdown
Contributor

Salvaged onto current main via #32270 (merged 2026-05-25). All 6 of your commits were cherry-picked with your authorship preserved (visible in git log on main). Two follow-up fixes on top:

  1. test(telegram): switch transient-flake retry test to group chat — the transient thread-not-found retry test was using chat_id="123" (positive = looks-like-private under the new contract). Switched to -100123 so the scenario is unambiguous against the new _is_private_dm_topic_send predicate.

  2. fix(telegram): exempt reply_to_mode=off DM topic sends from anchor-required guard — commit 21a15b6 (closes reply_to_mode: 'off'ignored by Telegram DM topic reply fallback code #23994) had previously verified that message_thread_id alone routes correctly on python-telegram-bot's reference client when the user has explicitly opted out of quote bubbles via reply_to_mode='off'. Carved that explicit opt-in out of the new fail-loud contract so users on reply_to_mode='off' aren't regressed.

Validation: tests/gateway/ (5915 pass), tests/cron/ + tests/tools/test_send_message_tool.py (504 pass), 4 E2E scenarios via real imports, 23/23 CI checks green. Thanks for the work — the named-topic creation, stale-thread refresh, and fail-loud-vs-General contract are all real wins.

daletkc pushed a commit to daletkc/hermes-agent that referenced this pull request May 25, 2026
…quired guard

Salvage follow-up. The new private-DM-topic fail-loud contract from
PR NousResearch#27107 hits 'requires a reply anchor' when reply_to_mode='off' is
configured, even though commit 21a15b6 (PR NousResearch#23994) verified that
message_thread_id alone routes correctly on python-telegram-bot's
reference client when the user has explicitly opted out of quote
bubbles. Carve out the explicit opt-in path so users on reply_to_mode
'off' aren't regressed — the new guard now only applies to callers
that didn't ask for the anchor to be suppressed.
bridge25 pushed a commit to bridge25/hermes-agent that referenced this pull request May 27, 2026
…quired guard

Salvage follow-up. The new private-DM-topic fail-loud contract from
PR NousResearch#27107 hits 'requires a reply anchor' when reply_to_mode='off' is
configured, even though commit 21a15b6 (PR NousResearch#23994) verified that
message_thread_id alone routes correctly on python-telegram-bot's
reference client when the user has explicitly opted out of quote
bubbles. Carve out the explicit opt-in path so users on reply_to_mode
'off' aren't regressed — the new guard now only applies to callers
that didn't ask for the anchor to be suppressed.
mathias3 pushed a commit to mathias3/hermes-agent that referenced this pull request May 28, 2026
…quired guard

Salvage follow-up. The new private-DM-topic fail-loud contract from
PR NousResearch#27107 hits 'requires a reply anchor' when reply_to_mode='off' is
configured, even though commit 21a15b6 (PR NousResearch#23994) verified that
message_thread_id alone routes correctly on python-telegram-bot's
reference client when the user has explicitly opted out of quote
bubbles. Carve out the explicit opt-in path so users on reply_to_mode
'off' aren't regressed — the new guard now only applies to callers
that didn't ask for the anchor to be suppressed.
Bryce-huang pushed a commit to wbkunlun/hermes-agent that referenced this pull request May 29, 2026
…quired guard

Salvage follow-up. The new private-DM-topic fail-loud contract from
PR NousResearch#27107 hits 'requires a reply anchor' when reply_to_mode='off' is
configured, even though commit 21a15b6 (PR NousResearch#23994) verified that
message_thread_id alone routes correctly on python-telegram-bot's
reference client when the user has explicitly opted out of quote
bubbles. Carve out the explicit opt-in path so users on reply_to_mode
'off' aren't regressed — the new guard now only applies to callers
that didn't ask for the anchor to be suppressed.

#AI commit#
mosaiq-systems pushed a commit to mosaiq-systems/hermes-agent that referenced this pull request May 29, 2026
…quired guard

Salvage follow-up. The new private-DM-topic fail-loud contract from
PR NousResearch#27107 hits 'requires a reply anchor' when reply_to_mode='off' is
configured, even though commit 21a15b6 (PR NousResearch#23994) verified that
message_thread_id alone routes correctly on python-telegram-bot's
reference client when the user has explicitly opted out of quote
bubbles. Carve out the explicit opt-in path so users on reply_to_mode
'off' aren't regressed — the new guard now only applies to callers
that didn't ask for the anchor to be suppressed.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…quired guard

Salvage follow-up. The new private-DM-topic fail-loud contract from
PR NousResearch#27107 hits 'requires a reply anchor' when reply_to_mode='off' is
configured, even though commit 21a15b6 (PR NousResearch#23994) verified that
message_thread_id alone routes correctly on python-telegram-bot's
reference client when the user has explicitly opted out of quote
bubbles. Carve out the explicit opt-in path so users on reply_to_mode
'off' aren't regressed — the new guard now only applies to callers
that didn't ask for the anchor to be suppressed.
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