fix(kanban): auto-subscribe notifications for agent-created tasks - #25357
Closed
zhanglib1996 wants to merge 2 commits into
Closed
fix(kanban): auto-subscribe notifications for agent-created tasks#25357zhanglib1996 wants to merge 2 commits into
zhanglib1996 wants to merge 2 commits into
Conversation
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
Collaborator
Author
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Tasks created by typing
/kanban createin a chat were auto-subscribed to notifications. But tasks created by an agent via thekanban_createtool 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_createinkanban_tools.py. After a task is created, it reads the gateway session context (platform,chat_id,thread_id) viagateway.session_context.get_session_envand 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_createcalls_try_auto_subscribeafter successful creation_try_auto_subscribe()helper reads gateway session context and callskb.add_notify_sub()ImportError-> silent skip (not in gateway)tests/tools/test_kanban_tools.py:test_create_no_subscription_outside_gateway— no subscription in non-gateway contexttest_create_auto_subscribes_in_gateway_context— creates subscription with correct platform/chat_idtest_try_auto_subscribe_creates_subscription— unit test for the helper function itselfBackward Compatibility
INSERT OR IGNOREprevents duplicatesCloses: #25195