Repository navigation
feat(slack): a code channel's Stop also stops its helper agents - #38243
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The removed idle Notes
[DESIGN-REVIEWED] 392d34e Description read[DESCRIPTION-READ] e6582ec0a2060b0b798e66ec3023a25ccefd828428fec520ba8c11df3c640568 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The base RFC ( Notes
What this change shipsInventory (9 items) — 7 justifiedIntent: pressing Stop or
[FIRST-PRINCIPLES-REVIEWED] 392d34e Description read[DESCRIPTION-READ] 9e2d8defe7359fac3b4788fd7455ca5b85c8681b7fc418c3b156052beb7ff580 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
074e432 to
e23f788
Compare
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR does what it says: Stop or !stop in a code channel now also stops the running turns of the helpers the store records (store().workers_of, written at each helper's birth) and cancels their sub-agents with the same cancel_for_parent call as the dashboard's Stop all. Each helper is stopped with stop_slot_turn(escalate=True), so a second press escalates; helpers already soft-stopping or compacting are not pressed twice by one Stop. Failures and mid-call cancellation are audited and not counted. The channel's own stop, audit, status settle and compaction notice behave as on main; the change is that Stop now posts a count, as the RFC asks. The owner, origin and workspace checks are unchanged and the stop fence is still set before any await. The removed interim idle reply has no remaining callers. CI is green and all AI review lanes passed. The RFC's hold (keeping stopped sessions stopped) is openly deferred to a follow-up PR and documented, which is a normal staged delivery, not a defect in this change. Tier: 2, held for a person: the title's category is not one of fix, test, chore, refactor. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
|
This changes behaviour users already rely on, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). The PR cites the RFC amendment merged in #35935 as its design input. A maintainer confirms whether that amendment covers this shape. Review result on this head: no blocking findings. The review checked these points:
The 31 new tests pass, and 30 of them fail against the merge-base tree, as the body says. Well done: the race tests are written so that removing the concurrency or the ordering turns them red. Optional:
|
e23f788 to
2a0f0e3
Compare
Slack's Stop and !stop in a code channel now stop the channel's own running turn, the running turn of every helper agent the code-channel store ties to that session, and the sub-agents those turns started, and say how many they stopped, naming each stopped helper the work board shows. Nothing is held afterwards: a queued wake or a patrol can start a stopped helper again until the follow-up hold change lands. Implements the brake of RFC #35935.
…op out of routing The Stop's orchestration after the stop fence (the stops, the status settle, the SEL rows and the reply) moves from routing._stop_bound into stop_helpers.stop_channel, with _stop_channel_session beside it. routing keeps the fence, the status hold release and a thin call (routing.py 1,996 -> 1,925 lines). The stop order and both sub-agent sweeps are unchanged. The reply says how many were stopped, as the RFC says, and no longer names or links helpers: board_titles, NAMED, reply_text's titles/link_for and the link_builder hop are removed, so the board-scope count is read once, with no await before the send. Whether the channel's own session runs is read at the press, before any await, and carried to its stop, so a turn it starts during the first sub-agent sweep (the person's next message) is not stopped by the earlier press.
2a0f0e3 to
392d34e
Compare
|
Thanks for the notes. Handled on
|
Problem / Motivation
Goal: Pressing Stop (or typing
!stop) in a Slack code channel stops everything that channel has running: its own session's turn, every helper agent's turn, and their sub-agents.Today Stop in a code channel stops only the channel's own session (
_stop_boundinslack/code_channels/routing.py). Helper agents the session started keep editing code. When the session is idle,!stoponly says how many helpers are still running and points at the work board, so the person has to open each helper's chat and press Stop generation there.Why it matters
Stop is the person's brake. A Stop that leaves agents editing code is not a brake. The decision is recorded in the merged RFC amendment (#35935):
docs/request-for-change/rfc-slack-code-channels.md§3 "Stop".Not a goal
What changed (motivation → approach → change)
Goal → approach: Stop must reach exactly what the gateway itself recorded as the channel's helpers. So the helper set comes from
store().workers_of(<channel session>)(written at each helper's birth, write-protected from agents), never from the crew-log tree, whose parent edge follows adoption. Each running helper is stopped the way a person's press stops a turn (stop_slot_turn(escalate=True)), so a pending tool approval is rejected and a second press escalates to a hard stop, as the channel's own Stop already does.What was built:
slack/code_channels/stop_helpers.py.stop_helpers()stops the channel's session (passed in asown) and each running helper of it together (asyncio.gather, as Pause all does), so no helper waits out another's soft-stop budget. Sub-agents of the session and of each helper are cancelled first (subagents.cancel_for_parent, the dashboard's "Stop all"), because a parent's hard Stop stops the ones sharing its process itself and those would go uncounted, and once more at the end for any the stopping turns started. The cost of that order: the turns are stopped only once the first sub-agent sweep has returned (the samecancel_for_parentthe dashboard's Stop all awaits). It reads the helper records twice, before and after the stops, so a helper born or started during the Stop is stopped too. A helper whose turn ended meanwhile answers "not running" and is not counted (Pause all's_NOT_STOPPEDrule).reply_text()builds the reply.routing._stop_boundstays thin. The stop fence (surface.mark_stopped) is still the first thing, before any await, followed by the status hold release. Everything after that (the channel's own stop in_stop_channel_session, the helper stops, the status settle, one SEL row per stop call, and the reply) isstop_helpers.stop_channel, sorouting.pygoes from 1,985 lines on main to 1,935 (the cap is 2,000). The reply says how many it stopped: "Stopped N: this channel's session, K helper agents and M sub-agents." It names no helper. A helper whose compaction declined the stop is said so, on!stopand on Slack's Stop alike. A helper stop that is refused or raises is not counted, is audited asresult=error, and the reply says how many could not be stopped (never "Nothing running." while one still runs). The same goes for the channel's own stop raising and for a sub-agent sweep that fails:cancel_for_parentdeliberately skips its running sweep when its queued pass raises, so the reply says those sub-agents could not be stopped. With nothing stopped and nothing to report,!stopsays "Nothing running." and the native Stop posts nothing, as today. A running session the board shows that the store does not record as a helper (a chat filed in the channel's folder, an adopted crew-log child) is not stopped; the reply counts it as still running, and that count is read right before the send and is 0 when the board's scope refuses the channel. The reply does not say that nothing starts again, because nothing is held yet._idle_stop_textand its idle!stopreply ("This channel's session isn't running, but N helper agents still are", naming and linking them): with the helpers stopped by the same press, that case no longer happens at reply time.src/kiro_crew/docs/slack-integration.mdand "What a Stop covers" indocs/system-specs/modules/slack-gateway.md. Both say plainly that a queued wake or a patrol can start a stopped helper again until the hold PR lands. "When a board write goes out" is unchanged from main: the Stop reply carries no helper content. The RFC is not edited.No dashboard file changes: the brake needs nothing from the send, continue, regenerate, rewind, queue drain, dispatch gate, session create, session messaging, AutoNudge, Slack inbound or restart resume paths.
What this PR removes from #38181, and why
#38181 (merged,
c8c236a555) put an interim idle!stopreply on main: while the channel's session is idle but helper agents run, it names up to five of them, linked to their chats. The RFC says it exists only "until the amended Stop ("Stop", below) is built" (rfc-slack-code-channels.md, Idle!stop), and this PR builds that Stop, so the same press now stops those helpers and the interim reply can no longer happen. Removed with it:routing._idle_stop_textand the idle block of_stop_boundthat posted it (with thelink_builderhop it needed and the now unusedCallableimport);board/render.py:STOP_NAMEDandidle_stop_text;workspace/board_cache.py:running_helpers(the(key, title)list), replaced bywatched_sessions, the Stop reply's count of board sessions it does not reach;test_bang_stop_with_helper_agents_running_says_where_to_stop_one,test_an_idle_stop_names_helpers_only_if_the_board_still_admits_them_at_the_sendand arunning_helpers=fake line (test_slack_code_channels_routing.py), the fourtest_the_idle_stop_reply_*tests (test_slack_code_channel_board.py), andtest_running_helpers_names_the_watched_sessions_running_but_the_channels_own, which becomestest_watched_sessions_are_the_watchs_sessions_but_the_channels_own;!stopwhile only helper agents run links each one", and the spec's idle-!stopparagraph and its entry under "When a board write goes out".Everything else #38181 added stays:
_worker_projects, the per-row PR and CI, the Code tab, the wrap-up outcomes and their docs. The RFC is not edited; its Idle!stopbullet describes the interim state that this PR ends.Review round (KiroCrewCaptain, 07:12Z, three optional notes)
Head:
392d34e1a38fd68b62c8cda14cce79969acda52f(the reviewed commit rebased onto main, plus a second commit, so the delta is reviewable on its own). The stop order and both sub-agent sweeps are byte-for-byte those ofe23f78827c, only moved; the one Stop change is the channel-session fix below.stop_helpers.py:179). Not taken. Sub-agents are cancelled by parent session, not by turn, so stopping the turns before or beside the sweep lets a Stop cancel sub-agents of the person's next turn. A faster brake needs turn-scoped cancellation in the sub-agent manager, which is a separate change.routing.pynear the line cap. Done: everything after the stop fence (the stops, the status settle, the SEL rows and the reply) moved tostop_helpers.stop_channel, with_stop_channel_sessionbeside it;routing._stop_boundkeeps the fence, the status hold release and a thin call.routing.pyis 1,935 lines on main after feat(slack): per-row PR and CI, the combined Code tab and wrap-up outcomes on the work board #38181 (the first commit alone puts it at 2,006, over the cap). The Stop tests ofe23f78827cpass unchanged apart from the naming ones;test_slack_code_channel_commit_point.py's module list is unchanged, sincerouting.pywas not in it and no covered write moved.board_titles,NAMED, thetitles/link_forparameters ofreply_textand thelink_builderhop are gone, with their three tests.test_the_reply_counts_the_stopped_helpers_and_names_none(fails one23f78827c) pins a count-only reply even when the board has a title for the helper. With the link builder's await gone, the board-scope count of sessions left running is read once, with no await before the send.Also in this round, from CI's GPT 6.1 Review on
2a0f0e3619(upheld): whether the channel's own session runs is now read at the press, before any await, and carried to its stop (one boolean, the channel's session only; helpers unchanged). So a message sent after an idle channel's Stop is not stopped, and neither is a helper report or wake that starts the channel's session during the sweep, as on main; holding it belongs to the follow-up hold PR.test_a_turn_the_channel_starts_during_the_first_sweep_is_not_stoppedfails without it;test_a_channel_session_running_at_the_press_is_stopped_after_the_first_sweepis its mirror.Backwards compatibility
Compatible: Stop still stops the channel's own session exactly as before (
stop_slot_turn(escalate=True), the compaction notice, theactivestatus, the same audit rows); it now also stops the running turns that session started. No config key, route, stored field or schema changes.Reader: src/kiro_crew/slack/code_channels/board/render.py:idle_stop_text -- chat -- its one reader on main was
routing._idle_stop_text(removed with it); the Stop reply is nowstop_helpers.reply_text-- test_bang_stop_in_a_code_channel_stops_the_bound_sessionReader: src/kiro_crew/slack/code_channels/routing.py:_idle_stop_text -- chat -- its one caller was
_stop_bound, which now answers throughstop_helpers.stop_channelandreply_text-- test_bang_stop_in_a_code_channel_stops_the_bound_sessionReader: src/kiro_crew/slack/code_channels/workspace/board_cache.py:running_helpers -- chat -- its one production caller was
_idle_stop_text;watched_sessionsreplaces it, read bystop_helpers.left_running-- test_watched_sessions_are_the_watchs_sessions_but_the_channels_ownTests
test/test_slack_code_channel_stop_helpers.py(new, 31 tests), throughrouting.inbound_gate(!stop) androuting.handle_session_stopped(Slack's Stop):cancel_for_parentraised, e.g. a busy task store) is said so on either Stop, never "Nothing running.", and stays said when a later sweep works (the failed one may have stopped some first);CancelledErrorfrom inside) is said and audited asresult=error, the rest still stop and the reply goes out; a refused channel-session stop is said, not counted;active);test/test_slack_code_channels_routing.pyandtest/test_slack_code_channel_board.py: #38181's idle-reply tests are removed with that reply (listed above), and a fake's unusedrunning_helpersis dropped.test/test_slack_code_channel_board_review_rounds.py: therunning_helperstest becomes thewatched_sessionsone.Fail-first: against origin/main's
src, every new test but the native-Stop-says-nothing guard fails; the tests added after publication (cancelled calls and sweeps, the partial sweep, the refused session stop, the folder session, the status race, the restarted helper) also fail against the published head074e4321d2; the count-only reply test of this round fails againste23f78827c.Not covered here: a shared user's Stop being refused (needs shared code-channel access, not on main). How a stopped approval's Slack card settles is already pinned in
test_slack_code_channel_worker_approvals.py(ended).Manual verification
N/A — the Stop's paths are covered through the real routing entry points; no live Slack workspace was used.
Related Issues
RFC:
docs/request-for-change/rfc-slack-code-channels.md§3 "Stop" (#35935). Follow-up: the hold PR (keeps stopped sessions stopped until a person writes).Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.