Skip to content

feat(kanban): per-call subscribe API with atomic notification subscription - #29913

Closed
crayfish-ai wants to merge 1 commit into
NousResearch:mainfrom
crayfish-ai:pr/kanban-atomic-subscribe
Closed

feat(kanban): per-call subscribe API with atomic notification subscription#29913
crayfish-ai wants to merge 1 commit into
NousResearch:mainfrom
crayfish-ai:pr/kanban-atomic-subscribe

Conversation

@crayfish-ai

Copy link
Copy Markdown
Contributor

Summary

Adds a subscribe= parameter to create_task() that creates a notification subscription inside the same write transaction as the task row, and wires it to the tool handler via gateway.session_context.get_session_env() and to the CLI via explicit --subscribe-* flags.

Changes (143 lines, 3 files)

kanban_db.py (+76/-1)

  • New _resolve_subscribe_dict() helper: normalises a caller-supplied subscribe dict
  • create_task(..., subscribe=...) parameter for per-call notification subscription
  • _add_notify_sub_inner() helper designed to run inside an existing write_txn
  • Subscription insert is inside create_task's write_txn — atomic with task creation

tools/kanban_tools.py (+24)

  • Tool handler resolves session context via gateway.session_context.get_session_env() (task-local contextvars, safe for concurrent gateway sessions)
  • Forwards notifier_profile from os.environ.get("HERMES_PROFILE")
  • Passes subscribe=... to create_task()

kanban.py (+44)

  • New _build_subscribe_from_args() helper
  • --subscribe-platform, --subscribe-chat-id, --subscribe-thread-id, --subscribe-user-id CLI flags
  • Includes notifier_profile from HERMES_PROFILE

Key differences from prior approaches

Aspect PR #28720 (flooryyyy) This PR
Transaction safety External call after task creation Same write_txn as task
Session source get_session_env() (correct) get_session_env() (correct)
Atomicity
Notifier profile Missing Included
CLI support --subscribe-* flags
Coverage Tool handler only Tool handler + CLI + programmatic
Diff size 34 lines, 1 file 143 lines, 3 files

Test Results

  • 167/167 kanban_db tests pass
  • 81/81 kanban_tools tests pass
  • 18/18 notify tests pass

…scription

Adds a subscribe= parameter to create_task() that creates a notification
subscription inside the same write transaction as the task row.

Key design decisions:
- DB-layer subscribe param on create_task() — atomic with task creation
- Session context is resolved at call sites via get_session_env()
  (task-local contextvars, not process-global os.environ)
- Tool handler resolves from gateway session context; CLI from explicit
  --subscribe-* flags
- notifier_profile is forwarded to support the gateway notifier watcher
- _add_notify_sub_inner() is the write_txn-safe helper for internal use

Unlike prior approaches, this does NOT rely on ambient environment variable
fallback inside the DB layer — every subscription must be explicitly
requested by the caller.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard comp/tools Tool registry, model_tools, toolsets labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants