Repository navigation
feat(session-control): let session_send steer a busy target's running turn - #11920
chenmingwei23 wants to merge 1 commit into
Conversation
|
Intent: Let one session correct a peer session while its turn is still running, by wiring |
5333050 to
31dcb97
Compare
|
All four red lanes on the previous head had a single cause, and it was mine.
The comment now states the condition in the present tense ("the RPC above Verified before pushing: New head: 31dcb97 |
Opus 4.8 Review (fork) —
|
First Principles Review (Fable 5, fork) —
|
Design Review (Fable 5, fork) —
|
GPT 5.6 Review (fork) —
|
… turn session_send could only start a turn or queue for the next one, so a caller watching a peer session go the wrong way had to wait out the work it wanted stopped. An optional steer flag now injects the message into the turn already running, through the same steer_into_running_turn path the dashboard composer uses. Both arms hand over the same redacted, provenance-prefixed text, so an injected message cannot read as human typing. A steer that cannot be injected falls back to the queue, and that fallback re-runs authorize_target because the steer RPC suspends: without it the queue would stamp a containment snapshot the authorization never saw. Closes kirodotdev#11919
31dcb97 to
77764a8
Compare
|
Superseded by #12048, which carries this exact commit from a same-repository branch. Verified before closing: both heads are the same commit Why the move was needed rather than a wait or an override. The two required review lanes never produced a verdict on this fork branch. Both check-runs read The same-repository review workflows carry no egress block at all, so #12048 can actually be reviewed. Everything else on this head was already accounted for: 89 lanes deduplicated to the newest run per workflow gave 75 success, 10 skipped, 2 neutral and zero pending, with |
Problem / Motivation
A session that sends to a busy peer has to wait for it.
session_sendcould onlystart a turn on an idle target or put the message in the queue, so a conductor
watching a worker head the wrong way could not say so until the worker finished
the work it wanted stopped. The tool's own description offered to "steer it
mid-run", which it could not do.
The same fleet pattern already behaves differently by worker type: a subagent can
be corrected mid-flight with
spawn_steer, a peer session cannot.Why it matters
Long turns are where the wait hurts. The worker spends minutes on work that is
already ruled out, and the correction is read after that work has landed, often
after it was pushed. The mid-turn path existed and only the composer could reach
it, so the cost was a missing wire, not a missing capability.
What changed (motivation, approach, change)
session_sendtakes an optionalsteer. On a busy target it cuts the messageinto the turn already running instead of queueing it, so the target reads the
correction while the work is still in flight.
steeromittedsteer: trueThe injection is the composer's own path,
steer_into_running_turn, not a secondmechanism. Both delivery arms hand over one text: redacted through
sanitize_outboundand prefixed with[sent by session <caller> via session_send]. So an injected message cannot read as something the person typed,which is the property that keeps app-authenticated composer sends off the steer
path.
Two things guard the new arm. The queue arm records the containment that held
when the message was admitted, and the drain re-asserts it, because a queued
message runs later than it was authorized. A steer runs inside the window
authorize_targetjust cleared, so there is nothing to re-check. The onesuspension the arm adds is the steer RPC itself, so a steer that cannot be
injected re-runs the gate before falling back to the queue. Without that, a
target that gained a channel link during the RPC would have that link stamped as
"held at admission" and the drain would read a widened audience as the authorized
one. A target whose key resolves to a different session during the RPC is refused
with
target_moved.steeris a delivery mode, not a permission.authorize_targetstill decides whomay send, and a crew-bound (
executor == "remote") target is still refused beforeeither arm. The flag is type-checked at both entry points, because the string
"false"is truthy and coercing it would interrupt a turn for a caller that askedfor the queue: the tool schema in
src/kiro_crew/validation.pytypes it strictlyand defaults it false, and the route in
src/kiro_crew/dashboard/handlers/session_control.pyrefuses a non-boolean withinvalid_steer. The delivery arms live insrc/kiro_crew/dashboard/session_control.py, andsrc/kiro_crew/mcp_dashboard.pydeclares the parameter, forwards it, and reportswhich of the three outcomes happened.
The result now carries
steeredbesidestarted, so a coordinator can tell aninjection from a started turn from a queued message.
The owning spec,
docs/system-specs/modules/session-control.md, gains the steerarm. Two sentences in the same section said the queued arm's second authorization
moment was unenforced and tracked as #5911; the drain re-check has since shipped
(
newly_held_constraints, called fromchat_runner), so they are correctedrather than left contradicting the paragraph above them.
Backwards compatibility
Compatible:
steerdefaults to false at both entry points, so a caller that omitsit keeps today's queue-or-run behaviour, and
steeredis an added response fieldrather than a changed one.
Tests
test/test_session_control.pycovers the delivery matrix against the realsteer_into_running_turnand a steer-capable client, not a stub: a steer lands inthe running turn and leaves exactly one transcript row with the provenance
envelope on both the injected text and the row; a client that cannot take it falls
back to the queue; a steer the turn's teardown requeued is not queued a second
time; an idle target never enters the steer path; and a busy target with a live
client still queues when
steeris not asked for.test_the_queue_fallback_re_runs_the_gate_after_the_steer_rpclinks the targetduring the RPC and asserts the send is refused with
linked_session_targetandnothing is queued. Removing the re-gate queues the message, which is the defect
the test exists for.
test/test_mcp_dashboard_session_send.pycovers the tool layer: what it forwards,the three outcome reports, and the schema refusing a non-boolean. The route's own
invalid_steerrefusal is tested beside the existing send route tests.Manual verification
Run in an isolated pod built from this branch, against a real kiro-cli backend.
No fixtures, no mocked event stream. Two sends, identical in every way except the
flag, both issued while the target was confirmed mid-turn.
Without
steer, the send queues:{"started": false, "steered": false}. Thetarget's transcript then holds TWO assistant turns -- it finished writing all 120
numbers first, and only answered the injected message afterwards, in a second
turn.
With
steer: true, the send is injected:{"started": false, "steered": true}.The transcript holds ONE assistant turn, and the injected row sits ahead of the
reply rather than after it.
The still frame below is the whole claim in one image: the peer's message rendered
with a
Steering...badge and its[sent by session <key> via session_send]envelope, the assistant's output still streaming underneath it (caught mid-word at
ninety-fi), the sidebar row readingStreaming, and the composer's stop buttonlive. The turn was running when the message landed.
steer-mid-turn.mp4
One thing this does not show, stated plainly: the model read the steer and chose
to finish counting anyway, closing with an offer to stop if asked directly. The
feature's contract is delivery into the running turn, which is what is proven
here. Whether the model obeys mid-stream is the model's business, not this
change's.
Also checked by hand:
{"steer": "false"}is rejected with HTTP 400invalid_steerrather than coerced true, and asteer: truesend to an IDLEtarget falls through to the normal start arm and reports
steered: false.recorded from 31dcb97 - worktree pod on an
isolated port and data dir - real server + real model, no fixtures
Related Issues
Fixes #11919
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)