Repository navigation
feat(session-control): session_reload relaunches a created session - #15499
Conversation
|
Intent: let an agent reload a session it created, the same relaunch the tab menu's Reload session performs, so a config change it made (MCP grant, agent spec) reaches that session without a human click and without losing the conversation. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS The route's post-pop teardown failure now answers 200 + [DESIGN-REVIEWED] 0449f50 Description read[DESCRIPTION-READ] 76e53b4e3aa6c47d8ede9d3e25deebce803953c671fb31d86a1e16905a013c34 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 (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the tab-menu route's 500→200-with-warning change: What this change shipsInventory (9 items) — 9 justifiedIntent: an agent can relaunch a session it created so a config change it made reaches that session without a human clicking Reload — ADDITION (linked issue #15449; auto-reload explicitly excluded as covered by RFC #15409,
Checks run: [FIRST-PRINCIPLES-REVIEWED] 0449f50 Description read[DESCRIPTION-READ] 0365b65655ce1c38aa94dcc25d56b7e0c5a79c8b69f6a33266dad6798c452400 That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
6fdc30c to
f4ca8fd
Compare
|
Rebased onto main after |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
f4ca8fd to
939f861
Compare
|
|
|
|
939f861 to
5901ad7
Compare
|
|
91b7918 to
ebce660
Compare
|
|
…agent process Adds a kirocrew-dashboard MCP tool and POST /api/session-control/reload. It reloads an idle session the caller created the way the tab menu's Reload session does: the agent process is torn down and the resume spawn re-armed, so the new process re-reads its agent spec, environment and MCP servers while the conversation is kept. The target's transcript gets the reload notice naming the calling session. The teardown moves out of api_chat_slot_reload into chat_handlers.reload_slot_session, which both the route and the verb call with their own authorization callbacks, so the lock order and re-checks are shared. The verb refuses self, not-created, remote-crew and busy targets (turn running or starting, queued messages, sub-agents) and re-runs its gate after every lock await. Blocked for channel agents and withheld from conductors and crew members.
ebce660 to
0449f50
Compare
|
chore (non-blocking): rebased onto main |
bolichen97
left a comment
There was a problem hiding this comment.
Approved: PR Readiness green on this head, merges cleanly into current main, no outstanding blocking review.
Problem / Motivation
Goal: an agent can reload a session it created, so a config change it just made reaches that session without the person clicking Reload in the tab.
A live session mounts its MCP servers and builds its tool table once, when its agent process starts. A server granted later, a Settings MCP toggle, or an agent-spec fix never reaches it. The tab menu's Reload session item (
POST /api/chat/slots/{slot}/reload) relaunches the process and keeps the transcript. No MCP tool does the same, so a conductor that changed a worker's MCP grant has to ask a human to click Reload, or close the worker and lose its conversation.Why it matters
Conductors that dispatch workers now also change their configuration (MCP grants, agent specs). Without a reload verb, each change needs a human in the loop or throws away the worker's context. This PR gives the verb to sessions acting on workers they created; it is withheld from conductor and crew-member grants for now, as
session_set_modelwas, so a conductor still gets an approval prompt until a later PR names the conductor step that needs it.Not a goal
session_set_modeland the dashboard pickers do that.What changed (motivation → approach → change)
The tab menu already has a correct teardown with two locks, three identity re-checks, a rebind check, a busy probe, a sub-agent probe and a
skip_if_busyreset with one retry. Copying it would let the two drift, so the locked body ofapi_chat_slot_reloadmoves intochat_handlers.reload_slot_session. The route and the new verb both call it and pass their own authorization as three callbacks (still_ours,denied,busy). The teardown passesstill_oursanafter_resetflag, so a caller knows whether the process is already gone without inferring it from call order. It also adds one re-check after the in-lock sub-agent probe, the last await before the reset. If the old process's shutdown raises after the session was popped, the teardown now finishes the reload (notice, respawn) and answers 200 with the switch handlers' existingold session teardown incompletewarning, using the same provider-identity probe as_reset_slot_session_or_warn; a raise before the pop still propagates. That is the one change to the route's responses: it used to answer 500 there.session_control.reload_targetis the verb:authorize_targetsupplies the usual containment (same workspace, persistent, not app-scoped, not channel-linked or mirrored, not a scheduled run) and refuses self-reload. A caller is mid-turn, so a self-reload could never succeed.not_creatorotherwise), for every caller class. A reload relaunches a process a person may be using, so this verb is narrower thansession_stop.remote_target_unsupported), assession_set_modeldoes.target_busybefore any lock is taken. The same probe runs again inside the locks.target_changed_during_reloadinstead of an ordinary refusal and is audited.kind, as the route's does. Allowed and denied calls are written to the SEL.Where each piece lives:
src/kiro_crew/dashboard/chat_handlers.py: the sharedreload_slot_sessionteardown, called byapi_chat_slot_reload.src/kiro_crew/dashboard/session_control.py:reload_target, the gate and busy checks above.src/kiro_crew/dashboard/handlers/session_control.pyandsrc/kiro_crew/dashboard/server.py:POST /api/session-control/reload, registered in the strict internal-secret route set.src/kiro_crew/mcp_dashboard.py,src/kiro_crew/validation.pyandsrc/kiro_crew/data/mcp_tool_titles.json: thesession_reload(target)tool, its schema and its title.src/kiro_crew/channel.py: the tool joinsCHANNEL_AGENT_BLOCKED_TOOLS.src/kiro_crew/agent.pyrecords it as withheld from conductors, and no crew-member grant includes it.src/kiro_crew/docs/session-control.md,src/kiro_crew/docs/index.md, and the architecture, feature-map and system-spec docs: the tool's documentation and its refusal codes.Backwards compatibility
Compatible: the tab menu route runs the same checks in the same order and returns the same responses. It gains one identity re-check after the sub-agent probe, so a slot replaced during that probe answers the existing
slot_not_found404 instead of being reset. The rest is a new tool and a new route.Tests
test/test_session_control_reload.pyhas 28 tests:allowed.target_changed_during_reload, audited).reload_failed(500), audited, with nothing torn down.target_changed_during_reloadas "reset, no notice" rather than "could not reload", renders a degraded-teardown warning as a completed reload, and takes no agent, model or workspace argument.test/test_pending_boundary_consumer_semantics.pygainsreload_targetin its list of busy-predicate readers, besideset_model_target.The in-lock gate, the re-check after the sub-agent probe, the in-lock busy probe and both post-reset branches were each checked by mutation: removing them makes a test fail. The registration, doc and refactor-contract tests were updated for the new tool.
Manual verification
N/A. No UI change. The route and verb are covered end to end through the aiohttp handler and the MCP tool dispatcher in the tests above.
Related Issues
Fixes #15449
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement