Skip to content

fix(webhook): surface DM topic routing keys in cross-platform delivery metadata - #33397

Open
liuhao1024 wants to merge 2 commits into
NousResearch:mainfrom
liuhao1024:fix/webhook-cross-platform-dm-topic-routing
Open

fix(webhook): surface DM topic routing keys in cross-platform delivery metadata#33397
liuhao1024 wants to merge 2 commits into
NousResearch:mainfrom
liuhao1024:fix/webhook-cross-platform-dm-topic-routing

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented May 27, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Surfaces direct_messages_topic_id and telegram_reply_to_message_id from deliver_extra into the cross-platform delivery metadata dict in the webhook adapter.

Related Issue

Fixes #33375

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • See commit messages for detailed changes

How to Test

  1. Run pytest tests/ -q — all tests should pass
  2. Verify the specific scenario described above is resolved

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4.1

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture and workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A

Code Intelligence

Checklist

  • Tests added (3 new test cases for DM topic routing key passthrough)
  • All existing tests pass (6/6 in TestDeliverCrossPlatformThreadId)
  • Backward compatible (existing deliver_extra configs without new keys are unaffected)
  • No unrelated files changed

…y metadata

When a webhook subscription targets a Telegram private DM with topics
enabled, the adapter previously only passed thread_id in metadata.
The Telegram adapter then demanded a reply anchor (telegram_reply_to_message_id)
that webhooks cannot provide, causing every DM-topic delivery to fail silently.

Now deliver_extra keys direct_messages_topic_id and
telegram_reply_to_message_id are surfaced in the metadata dict alongside
thread_id, allowing the Telegram adapter to route DM topic messages
without requiring an in-session reply anchor.

Fixes NousResearch#33375
@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/webhook Webhook / API server platform/telegram Telegram bot adapter labels May 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #33396 — both fix the same webhook DM-topic routing key forwarding bug in gateway/platforms/webhook.py. #33396 is more thorough: it forwards 4 routing keys (vs 2 here), adds type annotations, and has broader test coverage (5 tests vs 3).

@liuhao1024

Copy link
Copy Markdown
Contributor Author

Superseded by #33396 which covers the same fix more thoroughly — forwards 4 routing keys (vs 2 here), adds type annotations, and has broader test coverage (5 tests vs 3).

Closing this as a self-duplicate. The canonical PR is #33396.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the webhook metadata path.

Problems

  • The original #33375 anchor-error premise no longer follows current main: plugins/platforms/telegram/adapter.py:931-949 only enters the anchor-required DM fallback when telegram_dm_topic_reply_fallback is present, and gateway/platforms/webhook.py:1260-1266 does not provide that marker.
  • The forwarding list at gateway/platforms/webhook.py:1026 is incomplete for the current adapter contract. plugins/platforms/telegram/adapter.py:943 consumes telegram_dm_topic_created_for_send, and :993-1005 consumes telegram_dm_topic_reply_fallback; neither can be configured through this patch. The discussion-linked #33396 included both keys.

Suggested changes

  • Salvage this as four-key routing metadata passthrough with focused coverage for the two omitted keys.

Automated hermes-sweeper review.

if thread_id:
metadata = {"thread_id": thread_id}
# Surface Telegram DM topic routing keys when present in deliver_extra
for key in ("direct_messages_topic_id", "telegram_reply_to_message_id"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include telegram_dm_topic_created_for_send and telegram_dm_topic_reply_fallback here as well. The current Telegram adapter consumes those signals at plugins/platforms/telegram/adapter.py:943 and :993-1005; omitting them leaves two supported routing modes impossible to express through deliver_extra.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
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 platform/webhook Webhook / API server sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Webhook adapter drops telegram_reply_to_message_id from deliver_extra; all DM-topic webhook deliveries fail

3 participants