Repository navigation
feat(mcp): session_end_wait wakes a created session from the wait tool - #15166
Conversation
|
Intent: Let a session wake a worker it created from the |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
c43f6c9 to
0375a65
Compare
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 741a67d Description read[DESCRIPTION-READ] bb5194c01ea8c46ee175337d122e0897a3b9adcbe88c7ac5ed97231e42abdf0f 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 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify #15165 asks for this shape — the creator fence (owner sessions refused too) and the counted 30-minute cost both rest on that linked issue. The verb genuinely reuses the End-wait button's parked What this change shipsInventory (10 items) — 10 justifiedIntent: let a session wake a worker it created from the
[FIRST-PRINCIPLES-REVIEWED] 741a67d Description read[DESCRIPTION-READ] 6b185413d92fc8b7d6fceb9aeefe67640087f1d8786ef3178b275d627deabf5f That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
0375a65 to
28fc04e
Compare
|
self-added: yes
Also in this push: |
28fc04e to
6ece06b
Compare
|
note: rebased onto current main (6ece06b) with no code change, to re-run the two checks that failed on the CI app installation rate limit on 28fc04e: |
|
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. session_end_wait runs the shared authorize_target gate and then _created_by_other for every caller including owners (stricter than session_stop), failing closed on a blank _created_by; a worker cannot wake its creator and a subagent reaches only its parent's own workers. Route is in _STRICT_INTERNAL_API_PATHS and the tool is channel-blocked. No await between gate and write. control.py reads end_wait_by only from a reply naming this sleep, capped at 128 chars.
Non-blocking test gap: test_a_button_request_reports_the_user never seeds a stale _end_wait_by and never goes through api_chat_slot_end_wait, so deleting the clear at chat_handlers.py:5565 still passes; either add a route-level test with that seeding or clear _end_wait_by at every site that clears _end_wait_request (state.py:3927 says it needs no clearing, but none of the consume sites clear it).
Head branch was pushed to by a user without write access
|
070b63b to
eda6bf0
Compare
|
|
…l early Adds session_end_wait to kirocrew-dashboard. It parks the same end-wait request the dashboard's End wait button parks, aimed at the wait in flight on a session the caller created, via a new strict-internal /api/session-control/end-wait route. The keepalive reply now names a session requester so the woken wait's result says which session ended it.
eda6bf0 to
741a67d
Compare
|
Same-tree retrigger: |
iamwhatever
left a comment
There was a problem hiding this comment.
Re-approving: head 741a67d has the same tree (ad222e4aa5c8) as the head I approved earlier; timestamp-only re-push to clear a Windows shard flake in a test this PR does not touch.
Problem / Motivation
Goal: A session can wake a worker it created from the
waittool early, without cancelling the worker's turn.The dashboard's End wait button does this for a person, but the
kirocrew-dashboardMCP server has no equivalent. A conductor that already knows its worker's wait is over (the build finished, the PR merged) can only let the worker sleep out the rest of its wait (up to 30 minutes), stop the turn withsession_stop(discarding its work), orsession_sendit text (which ends the wait as a steer but also hands the worker a message to act on).Why it matters
Dispatch loops spend worker time asleep on a condition the conductor has already observed. Each such wait holds a turn and a subagent slot for minutes that do nothing, and the only faster options today either throw away work or inject an instruction the conductor did not mean to send.
Not a goal
session_end_waitstays out of_CONDUCTOR_DASHBOARD_GRANTSand_MEMBER_DASHBOARD_GRANTS. An unattended dispatch loop reaches it through trust mode, the session-level auto-approve an operator arms, which is the same pathsession_sendandsession_stopuse for a conductor. An attended loop approves it once. Adding it to the member grants (it is creator-fenced and discards nothing) is left to a maintainer as a follow-up.What changed (motivation → approach → change)
The button works by parking the in-flight
wait_idon the slot (_end_wait_request); the sleeping tool picks it up from its next keepalive reply and returns a normal result. The new tool reuses that mechanism instead of adding a second one. The browser route needs the caller to name await_idbecause a stale tab can show an old countdown; an MCP caller has no countdown, so the new verb reads the id from the slot at request time and can only name the sleep that is running now.session_end_wait(target)inmcp_dashboard.py, posting to a new strict-internal route/api/session-control/end-wait(added to_STRICT_INTERNAL_API_PATHSinserver.py).end_wait_targetindashboard/session_control.pyrunsauthorize_targetand then refuses any target the caller did not create (not_creator), including for an owner session the other verbs do not fence. On success it parks the request and records the caller in a new slot field,_end_wait_by. A target that is not sleeping, or whose wait is contested (two sleeps on one session key), getsended: falsewith aninfostring instead of an error. The SEL audit detail recordsrequested,not_waitingorcontested.handlers/sessions.py) carriesend_wait_bywhen a session parked the request. Thewaittool (mcp_tools/control.py) reads it only from a reply whoseend_waitnames its own sleep, and then returnsWait ended early by session <key> (session_end_wait) after Ns of Ms.The button route clears_end_wait_byso a click is still reported as the user.SESSION_CONTROL_TOOLSand toCHANNEL_AGENT_BLOCKED_TOOLSinchannel.py, documented as withheld from the conductor grants inagent.py, with a schema invalidation.pyand a title inmcp_tool_titles.json.session_end_waitsection indocs/session-control.md, tool counts indocs/index.md, the server row indocs/architecture/mcp.md, the Session control row and endpoint list indocs/feature-map/README.md, the keepalive reply contract indocs/system-specs/modules/learn-cron-dashboard.md, and a tool row plus an "Ending a wait early" section indocs/system-specs/modules/session-control.md.Backwards compatibility
Compatible: the keepalive reply only gains an optional field, and a
waittool that ignores them behaves exactly as before. Existing routes and tools are unchanged.Tests
test/test_session_end_wait.py: the verb parks the livewait_idand records the caller; a non-waiting target and a contested wait returnended: falsewithout parking anything; a peer the caller did not create is refusednot_creator; an ephemeral target is still refused by the shared gate; the keepalive reply carries the requester for a session request and none for a button request; the route refuses a caller without the internal secret, reaches the verb with it, and is in the strict-internal set; MCP dispatch posts the target, renders "Nothing to end" for a non-waiting target, and renders a refusal as an error; the audit detail namesrequested,not_waitingandcontestedapart.test/test_wait_tool_early_end.py: a session end names that session in thewaitresult; anend_wait_byon a reply for another wait is ignored.test/test_mcp_dashboard_registration.py,test/test_session_control_doc.py: the advertised set and the session-control group include the tool.Manual verification
N/A: the change is a server verb plus a field on an existing reply; the handoff between the verb, the keepalive handler and the
waitloop is covered end to end by the unit tests above.Related Issues
Fixes #15165
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)