Skip to content

fix(gateway): preserve kanban notifier chat type - #58615

Closed
ljsdut wants to merge 1 commit into
NousResearch:mainfrom
ljsdut:codex/kanban-notifier-chat-type
Closed

fix(gateway): preserve kanban notifier chat type#58615
ljsdut wants to merge 1 commit into
NousResearch:mainfrom
ljsdut:codex/kanban-notifier-chat-type

Conversation

@ljsdut

@ljsdut ljsdut commented Jul 5, 2026

Copy link
Copy Markdown

Summary

  • Persist chat_type on kanban_notify_subs, including legacy-table migration and rebuild specs.
  • Carry HERMES_SESSION_CHAT_TYPE through gateway session context so kanban_create auto-subscriptions record the source lane.
  • Rebuild notifier wakeup SessionSource with the subscription's persisted chat_type, falling back to group for old rows.

Root Cause

Kanban notifications delivered the text message to the subscribed chat, but the follow-up agent wakeup hardcoded chat_type="group". For DM-originated tasks, Hermes created or woke a synthetic group session instead of the PM's real DM session, so the PM often never saw the coder/QA completion in the active lane.

Tests

  • PYTHONPATH=/tmp/hermes-pytest-deps:. /home/ubuntu/.hermes/hermes-agent/venv/bin/python -m pytest tests/gateway/test_kanban_notifier.py -q
  • PYTHONPATH=/tmp/hermes-pytest-deps:. /home/ubuntu/.hermes/hermes-agent/venv/bin/python -m pytest tests/gateway/test_session_env.py tests/gateway/test_session_context_inheritance.py tests/gateway/test_async_delivery_capability.py -q
  • /home/ubuntu/.hermes/hermes-agent/venv/bin/python -m py_compile hermes_cli/kanban_db.py gateway/session_context.py gateway/kanban_watchers.py tools/kanban_tools.py gateway/slash_commands.py gateway/run.py tests/gateway/test_kanban_notifier.py
  • PYTHONPATH=/tmp/hermes-pytest-deps:. /home/ubuntu/.hermes/hermes-agent/venv/bin/python -m ruff check hermes_cli/kanban_db.py gateway/session_context.py gateway/kanban_watchers.py tools/kanban_tools.py gateway/slash_commands.py gateway/run.py tests/gateway/test_kanban_notifier.py

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/cron Cron scheduler and job management sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.
Duplicate of #56632 — both fix the kanban notifier wake mis-routing by persisting chat_type on kanban_notify_subs and rebuilding the wakeup SessionSource with it (carried via HERMES_SESSION_CHAT_TYPE). Same mechanism, 6 of 7 files identical (#56632 is earlier/canonical, targets #56580). Flagging for a maintainer to pick one.

@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 carrying the source lane through the notifier path. The premise is confirmed on current main: gateway/kanban_watchers.py:517-537 documents the missing provenance and hardcodes the wake source to chat_type="group".

Problems

  • hermes_cli/kanban.py:2439-2444 is a sibling notification-subscription writer that still supplies no chat type. A manually created DM subscription would remain NULL and hit this PR's group fallback in gateway/kanban_watchers.py.
  • The new gateway bridge in gateway/run.py is not directly covered: tests/gateway/test_kanban_notifier.py sets the ContextVar directly, while tests/gateway/test_session_env.py:33-72 does not assert HERMES_SESSION_CHAT_TYPE from _set_session_env().

Suggested changes

  • Add and thread a --chat-type value through hermes kanban notify-subscribe, with a DM wake regression test.
  • Add set-and-clear assertions for HERMES_SESSION_CHAT_TYPE through _set_session_env().

This is an automated hermes-sweeper review.

Comment thread gateway/run.py
return set_session_vars(
platform=context.source.platform.value,
chat_id=context.source.chat_id,
chat_type=(

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 add a direct regression assertion through _set_session_env(): the notifier test sets this ContextVar directly, so it would not catch this production bridge being omitted or cleared incorrectly.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages 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 15, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #72191 — your commit was cherry-picked onto current main with your authorship preserved in git log (05ab059). Your implementation won the arbitration among four competing PRs for this bug: earliest submission and the only one that fixed the auto-subscribe path end-to-end (ContextVar bridge + gateway stamp + schema with self-heal backfill), not just the slash-command site. Nice work.

@teknium1 teknium1 closed this Jul 26, 2026
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.
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 duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have 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.

3 participants