Repository navigation
feat(acp): steer claude turns through _session/steering - #14531
justin-robinson wants to merge 1 commit into
Conversation
|
Intent: On a claude session, a steer sent while a turn is running reaches that turn (over claude-agent-acp's |
4da3b2a to
78b11d3
Compare
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The description's own admission: live runs used the earlier revision (consume-on-injected, pre-#14115 install) — confirm the shipped clean-terminal settlement once on live 0.81.2. What this change shipsInventory (9 items) — 7 justifiedIntent: a mid-turn message on a claude dashboard session reaches the running turn instead of silently queueing — an ADDITION (new backend capability), grounded in a measured adapter behavior and the existing #14115 model.
Counts run: [FIRST-PRINCIPLES-REVIEWED] 682fbe0 Description read[DESCRIPTION-READ] 7fbb53d1325e139bae7cfa67a2e5b7179481abc212f41a5de10ed9f9efeb1aab That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS A Watch
[DESIGN-REVIEWED] 682fbe0 Description read[DESCRIPTION-READ] 59b3513fc4fc1a135453a6eb7538e500cbc530834bf694cbe9cc799fd0e3525e 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) — 🔴 changes requested (blocking)Reviewed 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING -- src/kiro_crew/acp/client.py:10054 -- malformed response IDs crash active turns Adjudication (Opus 5) — is blocking on each finding proportionate?F1 — harm rung: MEDIUM–HIGH crash/data-loss class (the in-flight turn dies; |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
78b11d3 to
682fbe0
Compare
Reworked onto #14115 (head
|
| Prior finding | Answer |
|---|---|
opus — claude in ACP_BACKENDS_STEER makes every messaging channel ack a mid-turn message as folded, then drop it; only the dashboard requeues |
Fixed. claude is in ACP_BACKENDS_STEERING_REQUEST, so steer_needs_loss_recovery is True and the provider wrapper refuses: channels, Side Chat and spawn_steer queue, exactly as for codex. Only the dashboard composer steers. |
opus — harness-parity.md H6 still guarantees membership implies one verb |
Fixed. H6, harness-onboarding.md, messaging.md and injected-messages.md now describe claude on AcpClient over the steering request; ACP_BACKENDS_STEER still means _session/steer. Both properties read the tables, not == ACP_BACKEND_CLAUDE. |
| gpt — ambiguous drain failure can duplicate a claude steer | Fixed. A failed write keeps the registration and returns True, so the pending entry settles once: consumed if an injected answer is read before a clean terminal, otherwise requeued. The log names AcpProcessDied when that is the cause. |
| design — provider behavior on the adapter users run is an unverified premise | Fixed. Verified on unmodified claude-agent-acp 0.81.2: the advertisement in initialize, a steer at a tool call, a steer during a text-only answer, and a dashboard steer. Results and their caveats are under Manual verification. |
design — gate the claude route on initialize._meta.steering.supported |
Fixed. The route sends only when the adapter advertised it; otherwise the caller queues. The parser and the handshake wiring are both tested. |
| first-principles — deny paths ride along on membership | Fixed. supports_refusal_steer is ACP_BACKENDS_STEER only, so claude's deny notices keep the refusal-recovery path. Nothing depends on the unverified pending-permission case. |
first-principles — delivery: "next" is unverified on a released adapter |
Fixed by deletion. The key is gone; only idleBehavior: "promptRequired" is sent. |
Two things worth a reviewer's attention, both mine rather than a lane's:
- A follow-up review of the first rework found that
stream_eventsclears_turn_donebefore the prompt frame is written, sohas_active_turn()was already True while the served prompt still named the previous one. A steer in that window could be injected into the new turn, dropped as stale, and requeued, running twice. A steering request is now admitted only while a dispatch loop is serving a prompt, and is aimed at that prompt. - Adding that lifetime to
_dispatch_eventswould have re-indented ~400 lines of it. The body moved unchanged into_dispatch_events_loopand_dispatch_eventsis a thin wrapper, which is why five source-inspecting tests now name the inner generator. The diff is byte-identical with and without-w.
Delivery is at-least-once by construction, as on the handle: the docstrings say so, and the requeue's visible duplicate is preferred to a silent loss.
|
A targeted |
claude-agent-acp has no _session/steer, so a mid-turn steer on the claude backend was refused and queued as a new turn. The adapter speaks the ACP steering request instead and advertises it as initialize._meta.steering.supported. - ACP_BACKENDS_STEERING_REQUEST gains claude; ACP_BACKENDS_STEER stays the _session/steer set, so claude's deny notices keep the refusal-recovery path (supports_refusal_steer False). - AcpClient answers supports_steer and steer_needs_loss_recovery from the tables, so only the dashboard composer steers claude; channels, Side Chat and spawn_steer queue, as for codex. - AcpClient.steer sends _session/steering fire-and-forget with idleBehavior=promptRequired, only when the adapter advertised it and within the handle's bounds. A failed write keeps its registration, so the pending entry settles exactly once. - The turn's dispatch loop settles the answer by request id and reports EVENT_STEER_CONSUMED only for an injected answer read before a clean end_turn terminal; any other ending leaves the steer for the turn-end requeue. Answers aimed at an earlier prompt are dropped. - The steering method, outcomes, bounds and outcome parser move to acp/types.py so the session handle and AcpClient share them.
682fbe0 to
323835f
Compare
|
|
|
Problem / Motivation
Goal: On a claude session, a steer sent while a turn is running reaches that turn, instead of silently waiting in the queue.
On the claude backend the busy composer offers Steer, but every mid-turn message is queued and runs as a separate turn after the current one ends.
ACP_BACKENDS_STEERis{kiro, KAS}, sosteer_into_running_turnreturnsSTEER_UNAVAILABLEfor claude and the message falls back to the queue. Nothing in the UI says the steer was downgraded.Why it matters
A user correcting a claude turn mid-flight ("stop, you're editing the wrong file") has to wait for the wrong work to finish, or press Stop and resend, which throws away the in-flight work. That's exactly what Steer is meant to avoid.
Not a goal
_session/steerpath andsteering_consumedecho are unchanged.What changed (motivation → approach → change)
Root cause. claude-agent-acp has no
_session/steer. It does implement the ACP steering request_session/steeringand advertises it asinitialize._meta.steering.supported. That's the same request codex speaks, and #14115 built the model for it:ACP_BACKENDS_STEERING_REQUEST,supports_refusal_steer,steer_needs_loss_recovery, and at-least-once settlement. It wired that model only intoAcpSessionHandle, but claude runs on the legacyAcpClient, so claude never reached it.Approach. Put claude into #14115's model rather than beside it. This revision replaces the earlier one, which put claude in
ACP_BACKENDS_STEER. That review round found it made messaging channels drop a steer the adapter didn't inject, opted claude into untested in-band deny notices, and broke the H6 table guarantee.Change.
ACP_BACKENDS_STEERING_REQUEST = {codex, claude}.ACP_BACKENDS_STEERis unchanged ({kiro, kas}, still meaning_session/steer).AcpClient, by table rather than by backend name:supports_steer: True forACP_BACKENDS_STEER ∪ ACP_BACKENDS_STEERING_REQUEST.supports_refusal_steer:ACP_BACKENDS_STEERonly, so claude's deny notices keep the refusal-recovery path.steer_needs_loss_recovery: True forACP_BACKENDS_STEERING_REQUEST. The provider wrapper then refuses, so channels, Side Chat andspawn_steerqueue, as they do for codex. Only the dashboard composer steers, and it requeues whatever isn't reported consumed.AcpClient.steerroutes steering-request members to_steer_via_steering_request. It's fire-and-forget, because the turn's dispatch loop is this client's only stdout reader._meta.steering.idleBehavior: "promptRequired", so a steer that reaches the adapter after the turn ended is answeredpromptRequiredand starts nothing.injectedanswer is read, otherwise requeued by teardown._dispatch_eventssettles answers:injectedfor the prompt being served marks the text proven.EVENT_STEER_CONSUMEDonly at a clean terminal (not cancelled, no refusal, stop reason exactlyend_turn), the same allowlist as_release_proven_steerson the handle.steering_outcomemove fromsession_handle.pytoacp/types.py, becausesession_handleimportsclient. The handle imports them from there.AcpClient.Alternative considered. A concurrent second
session/prompt(claude-agent-acp'spromptQueueing). Rejected: that creates a second adapter turn with its ownPromptResponse, which this client's single-turn read loop doesn't own.Backwards compatibility
Compatible:
spawn_steermessages on claude still queue.With a pre-empting steer, claude-agent-acp releases before the fixes in #958 and #1166 could end a turn before the steered work finished. On 0.63.0 we saw
-32603 [ede_diagnostic] result_type=user ... stop_reason=null. The runs below are on 0.81.2.Tests
test/test_acp_claude_steering.py(new, 36 tests):idleBehavior, nodeliverykey);initializehandshake recording it, and the gates on advertisement and active turn;injectedanswer then settles;end_turn, one echo per steer;max_tokens, empty-reason or error terminals, or on a cancel flag with anend_turnterminal;promptRequired,startedNewTurn,failed, non-object and error answers settling nothing;supports_steerFalse, nothing written).test_harness_parity.py(test_steer_is_opt_in, plus a new per-backendtest_client_steer_capabilities_match_the_steer_tables),test_acp_capability_sets_leaf.py,test_acp_client_more_coverage.py, andtest_codex_steering_request.py(membership pin, constants now inacp/types.py).test/test_acp_*.py,test/*steer*.py, parity, codex-steering, backend-cards, deny-notice, approval and channel-activation suites: 5705 passed. The 52 failures intest_acp_runtime.py(KAS readiness / worker identity) are identical by name on unmodifiedmainin this environment, so they're unrelated.mypy src/kiro_crew/(clean), the comment-history gate anddocs-lint.sh.Manual verification
All on unmodified claude-agent-acp 0.81.2:
initializecarries_meta.steering.supported: true.injected, the commands stopped, the reply followed the steer, and the turn endedend_turn.injected, the answer was cut off and replaced by the steered reply, and the turn endedend_turnwith no error.These runs used the earlier form of this change on a 0.8.0.3 install, which predates #14115. It sent the same request, but reported the steer consumed as soon as the
injectedanswer arrived rather than at the clean terminal. The two scripted runs droveAcpClientdirectly.Not verified live: a steer injected while a claude permission request is pending. The adapter delivers it at priority
later;supports_refusal_steerstays False, so no deny-notice path depends on it.Related Issues
Checklist