Skip to content

fix(kanban): preserve Telegram DM topic notification metadata - #60769

Closed
embwl0x wants to merge 1 commit into
NousResearch:mainfrom
embwl0x:agent/fix-kanban-dm-topic-notify
Closed

fix(kanban): preserve Telegram DM topic notification metadata#60769
embwl0x wants to merge 1 commit into
NousResearch:mainfrom
embwl0x:agent/fix-kanban-dm-topic-notify

Conversation

@embwl0x

@embwl0x embwl0x commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • persist per-subscription delivery metadata for Kanban notifications
  • carry Telegram DM-topic reply metadata from slash/tool auto-subscribe paths into notifier sends
  • add session chat type to the session context bridge so tool-created tasks can distinguish Telegram DMs from group/forum topics

Fixes #60600

Tests

  • uv run --extra dev pytest tests/gateway/test_kanban_notifier.py tests/hermes_cli/test_kanban_db_init.py tests/hermes_cli/test_kanban_core_functionality.py::test_notify_sub_crud tests/hermes_cli/test_kanban_notify.py::test_gateway_create_autosubscribes_on_explicit_board tests/tools/test_kanban_tools.py::test_create_subscribes_gateway_session tests/gateway/test_session_env.py -q
  • uv run --extra dev pytest tests/gateway/test_telegram_thread_fallback.py::test_base_gateway_metadata_marks_telegram_dm_topics_as_reply_fallback tests/gateway/test_delivery.py::test_explicit_telegram_private_thread_uses_reply_fallback_with_anchor -q
  • uv run --extra dev pytest tests/gateway/test_kanban_notifier.py tests/hermes_cli/test_kanban_notify.py tests/tools/test_kanban_tools.py -q
  • uv run --extra dev pytest tests/gateway/test_session_context_inheritance.py tests/gateway/test_session_env.py tests/tools/test_local_env_session_leak.py -q
  • git diff --check
  • gitleaks git --log-opts='origin/main..HEAD' --redact .

@alt-glitch alt-glitch added type/bug Something isn't working comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 8, 2026
@embwl0x

embwl0x commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Final overlap audit: #56632/#58615 persist chat_type so synthetic Kanban wakes land in the right DM/group session. This PR addresses the separate #60600 delivery failure: it persists and reuses the Telegram DM-topic reply anchor and fallback metadata required by the adapter safety guard, covering both slash-command and tool auto-subscribe paths. The prior PRs do not carry those send-time fields.

@embwl0x
embwl0x force-pushed the agent/fix-kanban-dm-topic-notify branch from c4e8494 to 98a8038 Compare July 10, 2026 09:40
@embwl0x
embwl0x marked this pull request as ready for review July 10, 2026 09:40
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for addressing the DM-topic delivery path. The premise is confirmed on current main: gateway/kanban_watchers.py:408-418 forwards only thread_id, while gateway/delivery.py:517-524 rejects a private-topic delivery without a reply anchor. The persisted replay metadata in this PR directly addresses that contract for both subscription writers.

Problems

  • The new HERMES_SESSION_CHAT_TYPE bridge lacks a direct regression assertion. tests/gateway/test_session_env.py:33-72 builds a SessionSource(chat_type="group") and calls _set_session_env(), but does not verify HERMES_SESSION_CHAT_TYPE; the tool-created subscription path now depends on it.

Suggested changes

  • Add set-and-clear assertions for get_session_env("HERMES_SESSION_CHAT_TYPE") in tests/gateway/test_session_env.py.

GitHub currently reports this PR MERGEABLE/CLEAN; current-main changes since its base do not touch its production files. This is an automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 10, 2026
@embwl0x
embwl0x force-pushed the agent/fix-kanban-dm-topic-notify branch from 98a8038 to 9e9cb25 Compare July 10, 2026 18:52
@embwl0x
embwl0x force-pushed the agent/fix-kanban-dm-topic-notify branch from 9e9cb25 to 1a0ebd6 Compare July 23, 2026 22:15
teknium1 added a commit that referenced this pull request Jul 26, 2026


Both the wake chat-scope salvage (#72191, merged) and the DM-topic
metadata salvage added HERMES_SESSION_CHAT_TYPE plumbing; the rebase
auto-merge kept both copies. Dedupe the ContextVar declaration, _VAR_MAP
entry, set_session_vars parameter/token, and the run.py call-site kwarg,
and prefer the persisted chat_type column with delivery_metadata as the
legacy fallback in the notifier wake path.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #72232 — both your commits (this one and #63927) were cherry-picked onto current main with your authorship preserved. The delivery_metadata persistence composed cleanly with the chat_type column that landed via #72191. Thanks for root-causing both halves of the DM-topic failure!

@teknium1 teknium1 closed this Jul 26, 2026
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
 with NousResearch#60769

Both the wake chat-scope salvage (NousResearch#72191, merged) and the DM-topic
metadata salvage added HERMES_SESSION_CHAT_TYPE plumbing; the rebase
auto-merge kept both copies. Dedupe the ContextVar declaration, _VAR_MAP
entry, set_session_vars parameter/token, and the run.py call-site kwarg,
and prefer the persisted chat_type column with delivery_metadata as the
legacy fallback in the notifier wake path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kanban notifications fail in Telegram DM topics without reply anchor

3 participants