Repository navigation
fix: resume a bot thread that a planned restart cut off - #35691
jingchaodev wants to merge 1 commit into
Conversation
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. The planned-restart boot resume now includes Bot threads ( 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 |
|
Gentle ping: could a maintainer approve the workflow runs for this fork PR when there is time? It merges cleanly with current main. Thanks! |
A planned restart records every chat with a turn in flight, and the next boot resumes them through the Resume-all run. That run keeps only the chat page's slot modes, the filter the Resume-all button needs for its count, so a Bot thread (slot mode member) was dropped and its work stopped until someone pressed Resume. collect_interrupted_idle and start_resume_all take a modes set that defaults to the chat page's. The restart passes the chat page's modes plus the member mode, so the button's count and candidates stay as they are. The Crew Mode roots whose workers stay with their conductor are still the chat page's rows, so a Bot's workers keep resuming. The run also took the press's user origin for every turn it resumed. A press is the owner's, but the boot is the gateway's: the cut turn may have been a check-in, a cron or a loop wake, and the record is a data-home file sandboxed code can write. start_resume_all takes a user_origin flag, the press keeps it, and the restart passes False, so no resumed turn can run an operation only a person's turn may run. Closes kirodotdev#35630
79948b5 to
6e1f160
Compare
Problem / Motivation
Goal: A Bot thread whose turn a planned restart cut resumes after the restart, as the chat page's sessions do.
After a planned restart (the dashboard Restart, an update apply, or
/kirocrew restartin Slack), a Bot thread (a Bot's own chat, slotmodemember) keeps its interruption row and its Resume button. The chat page's sessions and the Bot's own workers cut by the same restart are resumed.Why it matters
A Bot that is working when its owner restarts the gateway stops until someone opens the Bot's page and presses Resume. A planned restart is the app's own choice, so nothing should be left for the person to do. The reporter lost two cut Bot turns this way on 2026-11-11 (21:02 and 21:25 UTC).
Not a goal
design-critique): its app's page drives its turns, so the boot resume still leaves it out.member_slot_retry, about 120 s after boot): the resume pass has already run by then.What changed (motivation → approach → change)
record_running_slotsrecords every slot with a turn in flight, of any mode. The next boot resumes them throughchat_resume_all.start_resume_all, so the Resume-all run's bound and refusals apply. But that run'scollect_interrupted_idlekeeps onlyCHAT_PAGE_MODES(""and the retired"orchestrator"), the filter the button needs so its count matches the chat page's sidebar. The restart inherited the button's filter, so a recorded Bot thread was dropped.collect_interrupted_idleandstart_resume_alltake amodesargument whose default isCHAT_PAGE_MODES. The button route passes nothing, so its candidates are the same.resume_after_restartpassesCHAT_PAGE_MODES | {DM_SLOT_MODE}. The set of listed roots, whose Crew Mode workers stay with their conductor, is still built from the chat page's rows. A Bot's workers carrymate_root, nevercrew_root, so they keep resuming beside the Bot thread.""chat (Crew Mode roots, a Bot's workers, cron and task chats)"orchestrator"(retired, restored as"")"member"Bot threadThe run also gave every turn it resumed the press's user origin, which a press earns because the owner made it. The boot is the gateway acting: the cut turn may have been a Bot's check-in, a cron or a loop wake, and the record is a data-home file that sandboxed code can write. So
start_resume_alltakesuser_origin, the press keepsTrue, andresume_after_restartpassesFalse, as session control's Continue does. A restart-resumed turn, a Bot thread's or a chat page session's, then cannot run an operation that only a person's turn may run.Sub-agents run outside the dashboard's slots, so the record never names one.
learn-cron-dashboard.mdnames the modes the boot resumes and the origin its turns carry.Open PR #20750 edits
restart_resume.pytoo: whichever PR lands second passesmodes=CHAT_PAGE_MODES | {DM_SLOT_MODE}where_planned_candidatescallscollect_interrupted_idle.Backwards compatibility
Breaking: a turn the planned-restart boot resumes no longer counts as one the person sent, for a chat page session as for a Bot thread, so an operation only a person's turn may run refuses inside it until the person sends again. Writer sweep on origin/main @ b6091e4:
start_resume_allhas two callers. The Resume-all route keepsuser_origin=True, andresume_after_restartpassesFalse(changed here).Reader: src/kiro_crew/dashboard/handlers/guide.py:_resolve_agent_caller -- chat -- a user-only operation refuses in a restart-resumed turn as in a loop wake; a Bot thread's own goal, milestones and check-ins cards stay admitted (test_a_planned_restart_resumes_no_chat_as_a_turn_the_person_sent pins the flag)
Reader: src/kiro_crew/directive_origin.py:user_origin_gate_admits -- chat --
set_project,reset_conversation,chat_tagandsuggest_followuprefuse in a restart-resumed turn, as in a loop wakeReader: src/kiro_crew/dashboard/session_directive_apply_slot.py:_nothing_to_do -- chat -- a restart-resumed turn may end quietly, as a loop wake may; the transcript keeps the inspectable tool step
Reader: src/kiro_crew/dashboard/crew_dispatch_notice.py:maybe_write_dispatch_notice -- chat -- a restart-resumed conductor turn writes no dispatch notice, as its other automated turns do not
Reader: src/kiro_crew/dashboard/session_directive_apply_slot.py:_apply_chat_rename -- chat -- the agent's own chat rename refuses in a restart-resumed turn, as in a loop wake
Reader: src/kiro_crew/dashboard/chat_turn/turn_admission.py:_is_person_turn -- cron tab -- a restart-resumed turn in a cron tab starts its KAS session without the folder agent's hooks, as the cron's own runs do
Reader: src/kiro_crew/dashboard/handlers_instances_crew_reads.py:_slot_refusal -- crew page -- unchanged: a crew read needs
_turn_owner_sent, which no Continue sets, so a restart-resumed turn was refused before tooTests
test_a_planned_restart_resumes_a_bot_thread_it_recorded_once: a recorded, interrupted Bot thread resumes with a chat page session, once (a second boot dispatches nothing), while the button's candidates for the same slots stay the chat page session alone.test_a_planned_restart_resumes_no_chat_as_a_turn_the_person_sent: neither the chat page session nor the Bot thread the boot resumes carries the person's origin on its queue entry.test_resumes_every_candidate_with_the_pick_up_bodystill pins the owner's origin on a press.test_a_planned_restart_resumes_a_bot_threads_workers_but_not_a_listed_roots: a session the Bot thread dispatched still resumes, and a listed Crew Mode root's worker is still left to its conductor.test_a_recorded_bot_thread_is_refused_as_any_chat_is(approval,queue,sub-agents): a pending approval and a card queued in this process refuse the Bot thread with the button's codes, and running sub-agents keep it out of the run.test_a_boot_with_no_record_resumes_nothing(chat,bot-thread): a crash boot resumes neither.Proof: PROVEN test/test_chat_resume_all.py::test_a_planned_restart_resumes_a_bot_thread_it_recorded_once, test/test_chat_resume_all.py::test_a_planned_restart_resumes_no_chat_as_a_turn_the_person_sent, test/test_chat_resume_all.py::test_a_planned_restart_resumes_a_bot_threads_workers_but_not_a_listed_roots (head 6e1f160)
Determinism: the new and changed tests passed 20 of 20 runs at
-n0and 10 of 10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest/test_inapp_restart_keeps_turn_marker.pyandtest/test_restart_waits_for_cut_turns.py; the whole file passed in a shuffled order (seed 8542, 65 tests).Manual verification
N/A — unit coverage sufficient: the change is the candidate filter and the origin of the boot pass, and the tests drive
resume_after_restartfrom a written record over real slots, with only the turn dispatcher stubbed.Related Issues
Closes #35630
Related: #20750
Related: #13838
Sibling sweep
Swept: git grep -nE "collect_interrupted_idle|start_resume_all|CHAT_PAGE_MODES|continue_slot_turn(" -- src/
Sibling: src/kiro_crew/dashboard/restart_resume.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_resume_all.py -- not affected -- the Resume-all press keeps the chat page's rows and the owner's origin
Sibling: src/kiro_crew/dashboard/chat_api/continue_turn.py -- not affected -- the per-row Resume is the person's own press
Sibling: src/kiro_crew/dashboard/chat_api/slot_repair.py -- not affected -- the image repair route is the person's own press
Sibling: src/kiro_crew/dashboard/handlers/crew_pause.py -- not affected -- the Board's Resume is the person's own press
Sibling: src/kiro_crew/dashboard/session_control_parts/turn_control.py -- not affected -- an agent's Continue already passes no user origin
Sibling: src/kiro_crew/dashboard/limit_continue.py -- not affected -- the continue after a usage-limit reset is the person's own press, armed ahead of time
Sibling: src/kiro_crew/dashboard/slot_projection.py -- not affected -- a comment on the week-old interruption filter, which
collect_interrupted_idleapplies for everymodesSibling: src/kiro_crew/slack/code_channels/resume.py -- not affected -- the code-channel restart resume has its own path and store, and already passes no user origin
Pattern harvest
Rule candidate: review-prompt
Pattern: an automatic path that reuses a UI control's run inherits that control's display scope and the person's origin as its own
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; see the Licensing section of CONTRIBUTING.md.