Skip to content

fix(telegram): route resumed DM topic sends via direct_messages_topic_id#28488

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-6063e704
May 19, 2026
Merged

fix(telegram): route resumed DM topic sends via direct_messages_topic_id#28488
teknium1 merged 1 commit into
mainfrom
hermes/hermes-6063e704

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #27937 (@Qwinty).

Summary

After a gateway shutdown/resume, the final response goes through gateway/platforms/base.py::_thread_metadata_for_source. That helper marked Telegram private topics with telegram_dm_topic_reply_fallback but did NOT include direct_messages_topic_id. Resumed/synthetic events often have no message_id, so TelegramAdapter._thread_kwargs_for_send() returned {} for the no-anchor path and delivered to the root DM lane.

Complements #27212 (just merged) — which captures the triggering anchor for background-process notifications. This PR covers the resumed/synthetic-event path where no anchor is available at all by using Telegram's direct_messages_topic_id Bot API mechanism.

Changes

  • gateway/platforms/base.py: add direct_messages_topic_id to Telegram DM-topic thread metadata.
  • gateway/platforms/telegram.py: when no anchor is available, fall back to direct_messages_topic_id instead of returning {}.
  • tests/gateway/test_telegram_thread_fallback.py: regression coverage.

Validation

  • scripts/run_tests.sh tests/gateway/test_telegram_thread_fallback.py -q → 35/35 passing.

Conflict resolution

Docstring merge with #24004's reply_to_mode clarification (both edits to the same docstring; merged in favor of keeping both notes).

Authorship preserved via cherry-pick.

@teknium1 teknium1 merged commit de4cb55 into main May 19, 2026
@teknium1 teknium1 deleted the hermes/hermes-6063e704 branch May 19, 2026 05:04
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-6063e704 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8888 on HEAD, 8888 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4653 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

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.

3 participants