hermes - ✅(Solved) Fix Telegram /sethome loses forum topic thread ID and cron deliver=telegram prefers origin over home [1 pull requests, 1 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#18934Fetched 2026-05-03 04:53:30
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×5cross-referenced ×1

Fix Action

Fix / Workaround

The workaround was to make the cron target explicit:

PR fix notes

PR #19014: fix(gateway,cron): persist Telegram forum topic on /sethome

Description (problem / solution / changelog)

What does this PR do?

/sethome saved the bare chat_id to TELEGRAM_HOME_CHANNEL (and sibling *_HOME_CHANNEL env vars) and dropped the forum topic / thread id when run inside a Telegram forum topic. Cron reports configured for deliver: telegram landed in the parent chat instead of the configured topic, with no log signal and a successful-looking /sethome confirmation message.

The cron delivery code already supported chat_id:thread_id shape via deliver: telegram:<chat_id>:<thread_id> (parsed by tools.send_message_tool._parse_target_ref). This PR makes the home channel use the same encoding so the topic survives the env-var round trip.

Pre-#18934 env values without :thread_id continue to resolve as thread_id: None — no migration needed.

Scope: the /sethome topic-persistence sub-bug from #18934. The cron deliver=telegram prefers origin over home sub-bug is intentionally out of scope and could ship as a follow-up.

Related Issue

Fixes #18934 (sethome topic persistence; deliver origin-vs-home priority deferred)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/run.py_handle_set_home_command writes f"{chat_id}:{thread_id}" when source.thread_id is non-empty; confirmation message surfaces the topic id.
  • cron/scheduler.py — new _get_home_target(platform_name) returns (chat_id, thread_id) after parsing via _parse_target_ref. _get_home_target_chat_id wraps it for back-compat string callers. Both home-channel branches in _resolve_single_delivery_target (deliver=origin fallback, bare deliver=<platform>) hand the parsed thread id back.
  • tests/cron/test_scheduler.py — three new tests covering chat_id:thread_id, plain chat_id back-compat, and origin-fallback topic preservation.

How to Test

  1. In a Telegram forum topic, run `/sethome`. Check ~/.hermes/.env: TELEGRAM_HOME_CHANNEL=<chat_id>:<thread_id>. Confirmation message shows the topic id.
  2. Schedule a cron job with deliver: telegram from another chat.
  3. Before this PR: report lands in the parent chat. After: it lands in the configured topic.
  4. Existing pre-#18934 TELEGRAM_HOME_CHANNEL=<chat_id> values keep working.
  5. `pytest tests/cron/test_scheduler.py::TestResolveDeliveryTarget -q` → 30/30 pass.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and the touched suite passes
  • I've added tests for my changes
  • I've tested on my platform: macOS 15.x

Documentation & Housekeeping

  • I've updated relevant documentation — N/A (env var format is internal; the Telegram-topic shape was already documented for deliver: keys)
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A (env-var change only)
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture — N/A
  • I've considered cross-platform impact — N/A (gateway-side, no platform-specific code)
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Changed files

  • cron/scheduler.py (modified, +47/-8)
  • gateway/run.py (modified, +11/-2)
  • tests/cron/test_scheduler.py (modified, +67/-0)

Code Example

telegram:<chat_id>:<thread_id>

---

deliver: telegram

---

TELEGRAM_HOME_CHANNEL=<chat_id>

---

if platform_name == deliver_value:
    if origin and origin.get("platform") == platform_name:
        return {
            "platform": platform_name,
            "chat_id": str(origin["chat_id"]),
            "thread_id": origin.get("thread_id"),
        }

---

deliver: telegram
origin: telegram DM topic 13868
TELEGRAM_HOME_CHANNEL: group chat -1003984902686

---

telegram:-1003984902686:1
RAW_BUFFERClick to expand / collapse

Bug Description

Telegram home-channel delivery does not reliably work for forum topics, and cron delivery semantics for bare deliver: "telegram" are surprising/misleading.

There appear to be two related problems:

  1. /sethome stores only the Telegram chat_id, not the message_thread_id, so setting home from inside a Telegram forum topic loses the topic/thread.
  2. Cron jobs with deliver: "telegram" route to the job's same-platform origin before falling back to TELEGRAM_HOME_CHANNEL, which contradicts the user-facing/docs impression that a bare platform name means the configured platform home channel.

This is related to, but distinct from, #8866. That issue covers explicit delivery being influenced by home-channel state. This issue is about (a) home not preserving Telegram topic/thread information and (b) bare telegram preferring origin over home.

Expected Behavior

If /sethome is run in a Telegram forum topic, Hermes should persist enough information to deliver future cron/cross-platform messages back to that exact topic.

For example, home should effectively support:

telegram:<chat_id>:<thread_id>

Cron jobs with:

deliver: telegram

should deliver to the configured Telegram home destination, including thread/topic if configured. If origin-first behavior is intentional, docs and /sethome copy should say so clearly.

Actual Behavior

/sethome saves only the chat id:

TELEGRAM_HOME_CHANNEL=<chat_id>

It does not persist message_thread_id.

Additionally, cron delivery resolution for bare telegram prioritizes same-platform job origin before platform home:

if platform_name == deliver_value:
    if origin and origin.get("platform") == platform_name:
        return {
            "platform": platform_name,
            "chat_id": str(origin["chat_id"]),
            "thread_id": origin.get("thread_id"),
        }

In a real case, a cron job had:

deliver: telegram
origin: telegram DM topic 13868
TELEGRAM_HOME_CHANNEL: group chat -1003984902686

Target resolution returned the origin DM topic instead of the configured Telegram home channel.

The workaround was to make the cron target explicit:

telegram:-1003984902686:1

Reproduction

  1. Use Hermes gateway in a Telegram group/forum topic.
  2. Run /sethome from topic 1.
  3. Observe that TELEGRAM_HOME_CHANNEL stores only the group chat ID, not the topic/thread ID.
  4. Create a cron job from another Telegram chat/topic with deliver: "telegram".
  5. Observe that delivery resolves to the job's Telegram origin rather than the configured home channel.

Suggested Fix

  • Extend the home-channel model to preserve optional thread_id / Telegram message_thread_id.
  • Update /sethome to save topic/thread information when available.
  • Update cron delivery semantics so bare platform delivery (telegram) truly means platform home, or update docs/command copy if origin-first behavior is intentional.
  • Add tests covering:
    • /sethome in a Telegram forum topic persists thread id.
    • deliver: "telegram" resolves to Telegram home, not same-platform origin, when home is configured.
    • Explicit deliver: "telegram:<chat_id>:<thread_id>" continues to bypass home/origin and targets the exact topic.

Environment

  • Hermes Agent: current main checkout
  • Platform: Telegram gateway
  • Scenario: cron jobs delivering to Telegram forum topics

Impact

Medium/high for users relying on Telegram forum topics for scheduled reports. The current behavior makes /sethome look successful while cron reports silently land in the wrong Telegram topic/chat, or lose the topic entirely.

extent analysis

TL;DR

Update the home-channel model to preserve the optional thread_id and modify the /sethome command to save topic/thread information when available to fix the Telegram home-channel delivery issue.

Guidance

  • Extend the home-channel model to store both chat_id and thread_id for Telegram to ensure accurate delivery to forum topics.
  • Modify the /sethome command to save the message_thread_id when setting the home channel from within a Telegram forum topic.
  • Update the cron delivery semantics to prioritize the configured Telegram home channel over the job's origin when deliver is set to "telegram".
  • Add tests to cover the persistence of thread IDs by /sethome, the resolution of deliver: "telegram" to the Telegram home channel, and the behavior of explicit delivery specifications.

Example

No code snippet is provided as the issue description does not imply a specific code change but rather a design and functionality update.

Notes

The suggested fix involves updating the home-channel model and the /sethome command, which may require additional testing to ensure backward compatibility and correct functionality across different scenarios.

Recommendation

Apply the workaround by explicitly specifying the delivery target in the cron job configuration, such as deliver: "telegram:<chat_id>:<thread_id>", until the underlying issue is addressed by updating the home-channel model and delivery semantics.

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

hermes - ✅(Solved) Fix Telegram /sethome loses forum topic thread ID and cron deliver=telegram prefers origin over home [1 pull requests, 1 participants]