hermes - ✅(Solved) Fix Cron Telegram topic delivery drops explicit thread_id [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#16795Fetched 2026-04-29 06:39:05
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Timeline (top)
labeled ×4cross-referenced ×3commented ×1

Root Cause

Likely Root Cause

Fix Action

Fixed

PR fix notes

PR #16797: fix: preserve telegram cron topic delivery

Description (problem / solution / changelog)

Summary

  • Preserve explicit Telegram topic/thread ids in cron delivery targets like telegram:-1003724596514:345.
  • Avoid re-resolving already-explicit platform IDs through the channel directory, which can strip topic suffixes when the directory has an exact chat-id match.
  • Add a regression test for the exact failure mode.

Fixes #16795

Test Plan

  • /home/alex/.hermes/hermes-agent/venv/bin/python -m pytest tests/cron/test_scheduler.py::TestResolveDeliveryTarget::test_explicit_telegram_topic_target_with_thread_id tests/cron/test_scheduler.py::TestResolveDeliveryTarget::test_explicit_telegram_topic_keeps_thread_when_directory_has_chat_id tests/cron/test_scheduler.py::TestResolveDeliveryTarget::test_human_friendly_topic_label_preserves_thread_id -q -o 'addopts='

Notes

A full local tests/cron/test_scheduler.py run is affected on my live host by the running Hermes gateway holding the real cron tick lock; the targeted resolver tests pass and CI should not have that live-service lock.

Changed files

  • cron/scheduler.py (modified, +15/-11)
  • scripts/release.py (modified, +1/-0)
  • tests/cron/test_scheduler.py (modified, +15/-0)

PR #16815: fix(cron): preserve explicit thread_id in delivery target resolution (#16795)

Description (problem / solution / changelog)

Summary

Cron delivery targets that explicitly include a Telegram forum topic (e.g. telegram:-1003724596514:345) lose the topic/thread ID during channel-directory resolution. Messages land in the General topic instead of the configured topic.

Root Cause

_resolve_single_delivery_target() correctly parses telegram:chat_id:thread_id into chat_id="-1003724596514" and thread_id="345". But then it runs resolve_channel_name() on the parsed chat_id. When the directory has an exact match for the group chat ID, it returns just the chat ID (without thread). The second _parse_target_ref() call on this result returns thread_id=None, which overwrites the previously parsed "345".

Fix

Skip channel-directory resolution when the original target was already explicit (is_explicit=True). Human-friendly label resolution (e.g. "Alice (dm)" → real ID) should only run for non-explicit targets.

File changed: cron/scheduler.py (+3 lines, 1 indentation change)

Before/After

# Before: thread_id dropped
_resolve_single_delivery_target(job, "telegram:-1003724596514:345")
# → {"platform": "telegram", "chat_id": "-1003724596514", "thread_id": None}

# After: thread_id preserved
_resolve_single_delivery_target(job, "telegram:-1003724596514:345")
# → {"platform": "telegram", "chat_id": "-1003724596514", "thread_id": "345"}

Fixes #16795

Changed files

  • cron/scheduler.py (modified, +14/-11)

PR #16846: fix(cron): preserve Telegram topic delivery targets

Description (problem / solution / changelog)

What does this PR do?

Fixes cron delivery for explicit Telegram forum topic targets such as deliver: telegram:GROUP_ID:THREAD_ID.

Cron delivery parsed the original THREAD_ID correctly, but then resolved the bare GROUP_ID through the channel directory. When the directory returned just the bare group id, _resolve_single_delivery_target() replaced both chat_id and thread_id, dropping the already-parsed topic id. Telegram then received no message_thread_id and delivered to the default topic.

This changes the merge so a resolved channel id updates chat_id, but only replaces thread_id when the resolved value actually includes a thread/topic id.

Related Issue

Reported from Discord support: cron jobs using deliver: telegram:GROUP_ID:THREAD_ID landed in the group default topic when the bare group id existed in the channel directory.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • cron/scheduler.py: preserve an explicit thread_id when channel-directory resolution returns a bare chat id.
  • tests/cron/test_scheduler.py: add regression coverage for explicit Telegram topic delivery where the channel directory exact-id lookup returns the bare group id.

How to Test

  1. Configure a cron job with deliver: telegram:GROUP_ID:THREAD_ID.
  2. Ensure GROUP_ID exists in the channel directory as a bare id.
  3. Resolve or run the cron job and confirm the delivery target keeps thread_id: THREAD_ID.

Checklist

Code

  • I searched for existing PRs to make sure this is not a duplicate
  • My PR contains only changes related to this fix/feature
  • I added tests for my changes
  • I tested on my platform: Ubuntu/WSL-style Linux checkout

Documentation & Housekeeping

  • Documentation update: N/A
  • cli-config.yaml.example: N/A
  • CONTRIBUTING.md / AGENTS.md: N/A
  • Cross-platform impact considered: resolver-only change, platform-neutral
  • Tool descriptions/schemas: N/A

Validation

  • scripts/run_tests.sh tests/cron/test_scheduler.py — 94 passed
  • scripts/run_tests.sh — 34 failed, 16972 passed, 42 skipped. The failures were outside cron delivery and include existing unrelated areas such as DingTalk card mocks, gateway config expectations, Anthropic adapter beta headers, clipboard WSL detection, and TUI/session tests.

Screenshots / Logs

Before this change, resolving telegram:-1003724596514:17 while the channel directory returned -1003724596514 produced:

{"platform": "telegram", "chat_id": "-1003724596514", "thread_id": None}

After this change, the explicit topic id is preserved:

{"platform": "telegram", "chat_id": "-1003724596514", "thread_id": "17"}

Changed files

  • cron/scheduler.py (modified, +3/-1)
  • tests/cron/test_scheduler.py (modified, +16/-0)

Code Example

telegram:-1003724596514:345

---

from cron.scheduler import _resolve_single_delivery_target

print(_resolve_single_delivery_target(
    {"id": "test", "deliver": "telegram:-1003724596514:345"},
    "telegram:-1003724596514:345",
))

---

{"platform": "telegram", "chat_id": "-1003724596514", "thread_id": "345"}

---

{"platform": "telegram", "chat_id": "-1003724596514", "thread_id": None}
RAW_BUFFERClick to expand / collapse

Bug Description

Cron delivery targets that explicitly include a Telegram forum topic, e.g. telegram:-1003724596514:345, can be resolved without the topic/thread id. The final Telegram send then omits message_thread_id, causing scheduled job notifications to land in the group General topic instead of the configured topic.

Steps to Reproduce

  1. Have a Telegram supergroup with forum topics and a cron job configured with a topic delivery target such as:
    telegram:-1003724596514:345
  2. Ensure the channel directory contains an exact entry for the group chat id, e.g. -1003724596514.
  3. Resolve the cron delivery target through cron.scheduler._resolve_single_delivery_target / _resolve_delivery_target.

Minimal reproduction:

from cron.scheduler import _resolve_single_delivery_target

print(_resolve_single_delivery_target(
    {"id": "test", "deliver": "telegram:-1003724596514:345"},
    "telegram:-1003724596514:345",
))

Expected Behavior

The explicit topic target preserves the topic id:

{"platform": "telegram", "chat_id": "-1003724596514", "thread_id": "345"}

Telegram delivery should pass message_thread_id=345.

Actual Behavior

The topic id can be dropped and the target resolves like:

{"platform": "telegram", "chat_id": "-1003724596514", "thread_id": None}

Telegram receives no message_thread_id, so messages go to the General topic.

Likely Root Cause

_resolve_single_delivery_target() correctly parses telegram:chat_id:thread_id, but then runs channel-directory resolution on the parsed chat_id. If the directory has an exact match for the group chat id, it returns only the chat id and overwrites the previously parsed topic id.

Explicit platform IDs should not be re-resolved as human-friendly labels after parsing. Human-friendly label resolution should only run for non-explicit targets.

Environment

  • Component: cron delivery / Telegram gateway integration
  • Affected area: cron/scheduler.py
  • Target format: telegram:chat_id:thread_id

extent analysis

TL;DR

The issue can be fixed by modifying the _resolve_single_delivery_target function to preserve the topic id when resolving explicit Telegram targets.

Guidance

  • Verify that the _resolve_single_delivery_target function is correctly parsing the telegram:chat_id:thread_id format, but then overwriting the thread_id when resolving the channel directory.
  • Check if the channel directory resolution can be skipped for explicit platform IDs, allowing the previously parsed topic id to be preserved.
  • Consider adding a conditional statement to check if the target is an explicit platform ID before running the channel-directory resolution.
  • Test the modified function with the provided minimal reproduction code to ensure the topic id is preserved.

Example

def _resolve_single_delivery_target(target, delivery_target):
    # Parse the target
    platform, chat_id, thread_id = target.split(":")
    
    # Check if the target is an explicit platform ID
    if delivery_target.startswith(platform + ":"):
        # Preserve the topic id
        return {"platform": platform, "chat_id": chat_id, "thread_id": thread_id}
    else:
        # Run channel-directory resolution
        # ...

Notes

The provided code snippet and reproduction steps suggest that the issue is specific to the _resolve_single_delivery_target function and the channel directory resolution. The fix should focus on modifying this function to preserve the topic id for explicit Telegram targets.

Recommendation

Apply a workaround by modifying the _resolve_single_delivery_target function to preserve the topic id when resolving explicit Telegram targets, as this is a targeted fix that addresses the specific issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING