Skip to content

Fix Telegram topic routing for background process updates#1146

Closed
spanishflu-est1918 wants to merge 1 commit intoNousResearch:mainfrom
spanishflu-est1918:codex/telegram-topic-background-routing
Closed

Fix Telegram topic routing for background process updates#1146
spanishflu-est1918 wants to merge 1 commit intoNousResearch:mainfrom
spanishflu-est1918:codex/telegram-topic-background-routing

Conversation

@spanishflu-est1918
Copy link
Contributor

@spanishflu-est1918 spanishflu-est1918 commented Mar 13, 2026

Summary

Fix Telegram forum topic routing for background process progress/completion messages.

What changed

  • gateway/run.py
    • export HERMES_SESSION_THREAD_ID from the active session context
    • persist thread_id in background watcher metadata
    • send watcher notifications with metadata={"thread_id": ...} so Telegram replies land in the originating topic
  • tools/terminal_tool.py
    • include thread_id in pending watcher payloads

Why

In Telegram forum chats, background process updates were being delivered with only chat_id, which sends them to the default/general topic instead of the originating topic.

Related issues

Notes

This is a focused fix for background-process topic routing only. Mention/wake-gate behavior is intentionally not part of this PR.

@spanishflu-est1918 spanishflu-est1918 force-pushed the codex/telegram-topic-background-routing branch from 4cad856 to 5b91d81 Compare March 13, 2026 09:04
teknium1 pushed a commit that referenced this pull request Mar 16, 2026
… topics

Salvaged from PR #1146 by spanishflu-est1918.

Background process progress/completion messages were sent with only
chat_id, landing in the general topic instead of the originating forum
topic. Thread the thread_id from HERMES_SESSION_THREAD_ID through the
watcher payload and pass it as metadata to adapter.send() so Telegram
routes notifications to the correct topic.

The env var export (HERMES_SESSION_THREAD_ID in _set_session_env /
_clear_session_env) already existed on main — this commit adds the
missing watcher plumbing.
@teknium1
Copy link
Contributor

Merged via PR #1481. The core fix (watcher thread_id plumbing → adapter.send metadata) was salvaged onto current main with authorship preserved. The env var export part was already on main. Thanks for the contribution!

@teknium1 teknium1 closed this Mar 16, 2026
teknium1 added a commit that referenced this pull request Mar 16, 2026
… topics (#1481)

Salvaged from PR #1146 by spanishflu-est1918.

Background process progress/completion messages were sent with only
chat_id, landing in the general topic instead of the originating forum
topic. Thread the thread_id from HERMES_SESSION_THREAD_ID through the
watcher payload and pass it as metadata to adapter.send() so Telegram
routes notifications to the correct topic.

The env var export (HERMES_SESSION_THREAD_ID in _set_session_env /
_clear_session_env) already existed on main — this commit adds the
missing watcher plumbing.

Co-authored-by: spanishflu-est1918 <spanishflu-est1918@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background processes are lost when hermes-gateway restarts

2 participants