Skip to content

fix(kanban): auto-subscribe notifications for agent-created tasks - #25357

Closed
zhanglib1996 wants to merge 2 commits into
NousResearch:mainfrom
zhanglib1996:feat/kanban-auto-subscribe
Closed

fix(kanban): auto-subscribe notifications for agent-created tasks#25357
zhanglib1996 wants to merge 2 commits into
NousResearch:mainfrom
zhanglib1996:feat/kanban-auto-subscribe

Conversation

@zhanglib1996

Copy link
Copy Markdown

Problem

Tasks created by typing /kanban create in a chat were auto-subscribed to notifications. But tasks created by an agent via the kanban_create tool were not — the user had no visibility into when the task finished, blocked, or needed QC review, short of manually polling the board.

Solution

Add _try_auto_subscribe() to _handle_create in kanban_tools.py. After a task is created, it reads the gateway session context (platform, chat_id, thread_id) via gateway.session_context.get_session_env and registers a notify subscription.

Outside a gateway context (CLI, tests) the call is a no-op — no import error, no side effects.

Changes

tools/kanban_tools.py:

  • _handle_create calls _try_auto_subscribe after successful creation
  • New _try_auto_subscribe() helper reads gateway session context and calls kb.add_notify_sub()
  • Gracefully degrades: ImportError -> silent skip (not in gateway)

tests/tools/test_kanban_tools.py:

  • test_create_no_subscription_outside_gateway — no subscription in non-gateway context
  • test_create_auto_subscribes_in_gateway_context — creates subscription with correct platform/chat_id
  • test_try_auto_subscribe_creates_subscription — unit test for the helper function itself

Backward Compatibility

  • No changes to DB schema or CLI behaviour
  • No subscription in CLI/test contexts — zero side effects
  • Idempotent subscription: INSERT OR IGNORE prevents duplicates

Closes: #25195

When a task is created via the kanban_create tool inside a gateway
session (e.g. an agent running in Feishu/Telegram/Discord), the
originating chat is now automatically subscribed to terminal-state
events (completed, blocked, qc_review, gave_up, crashed, timed_out).

=== Problem ===
Tasks created by typing /kanban create in a chat were auto-subscribed
to notifications. But tasks created by an agent via the kanban_create
tool were not — the user had no visibility into when the task finished,
blocked, or needed QC review, short of manually polling the board.

=== Solution ===
Add _try_auto_subscribe() to _handle_create in kanban_tools.py.
After a task is created, it attempts to read the gateway session
context (platform, chat_id, thread_id) and registers a notify
subscription. Outside a gateway context (CLI, tests) the import of
get_session_env silently fails and the call is a no-op.

=== Changes ===
tools/kanban_tools.py:
  - _handle_create calls _try_auto_subscribe after successful creation
  - New _try_auto_subscribe() helper reads gateway session context and
    calls kb.add_notify_sub(); gracefully degrades when not in a
    gateway context (ImportError -> silent skip)
Three tests covering the auto-subscribe behaviour introduced in the
previous commit:

1. test_create_no_subscription_outside_gateway — verifies that
   _handle_create does NOT create a notify subscription in normal
   (non-gateway) context (regression guard)

2. test_create_auto_subscribes_in_gateway_context — mocks gateway
   session context via monkeypatch and verifies that _handle_create
   auto-subscribes the originating chat with correct platform/chat_id

3. test_try_auto_subscribe_creates_subscription — unit-level test of
   the _try_auto_subscribe helper: no-op without context, creates
   subscription when gateway session vars are available
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists labels May 14, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing implementation — same feature as #25195, #21523, #22190. Note: the original merge #19718 was reverted by #19721, so the feature is not yet live. Original issue: #19479.

@zhanglib1996

Copy link
Copy Markdown
Author

Closing — duplicate of #25195 (same feature, submitted earlier with child-subscription inheritance). Our implementation uses the same approach (get_session_env + lazy import) but #25195 is more complete. We defer to that PR. QC PR #25356 remains open as it is a distinct feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/tools Tool registry, model_tools, toolsets duplicate This issue or pull request already exists 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