Skip to content

feat(acp)!: replace injection with prompt delivery - #356

Open
danielkov wants to merge 17 commits into
mainfrom
feat/acp-prompt-delivery
Open

danielkov wants to merge 17 commits into
mainfrom
feat/acp-prompt-delivery

Conversation

@danielkov

Copy link
Copy Markdown
Contributor

Summary

Replace Kit's legacy ACP injection RPCs with the draft v2 prompt-delivery modes proposed in agentclientprotocol/agent-client-protocol#1261. The runtime, gateway, TUI, and Desktop use session/prompt.delivery for steering and queueing, messageId to reconcile insertion, and $/cancel_request to withdraw pending input.

Impact

ACP callers must negotiate capabilities.session.prompt.delivery before sending an explicit mode. session/cancel stops foreground work but preserves pending explicit steers and queued prompts. Ordinary prompts remain supported, and Kit's separate subagent steering mechanism is unchanged.

Technical details

Gateway compatibility

The gateway forwards withdrawal using the resident child's request ID and retries under bounded write backpressure. The updated SDK preserves bounded HTTP/SSE and graceful HTTP DELETE drain. Kit uses one published SDK/schema dependency graph.

@danielkov
danielkov enabled auto-merge (squash) November 20, 2026 16:34
@danielkov

Copy link
Copy Markdown
Contributor Author

@kit-code-agent review

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Six findings: a rollover steer can return the wrong child turn’s output; a late withdrawal can disconnect unrelated Gateway sessions; Stop can leave a structured worker’s next prompt waiting on detached work; Desktop can lose audio playback and newer draft attachments; and generated Swift records the wrong schema revision.

Took 37 min

Comment thread src/acp_child/protocol.rs Resolved
Comment thread src/gateway/http_server.rs Resolved
Comment thread docs/reference/gateway-protocol.md Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An ordinary child prompt can return a rollover steer's result. Gateway can silently lose a withdrawal under writer backpressure or disconnect unrelated sessions when a withdrawal races close. Desktop can open changed source audio instead of the echoed bytes, and saved drafts can crowd out the transcript.

Took 22 min

Comment thread src/tools/subagent.rs Resolved
Comment thread src/gateway.rs Resolved
Comment thread src/gateway/http_server.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A later Stop can overtake an accepted withdrawal under Gateway backpressure. Nested ACP capture can silently drop output before the matching echo or disconnect sibling sessions when its provisional output budget fills. Desktop creates an unmanaged playback copy each time a user opens echoed local audio.

Took 17 min

Comment thread src/gateway.rs Resolved
Comment thread src/acp_child.rs Resolved
Comment thread src/acp_child/capture.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A pending withdrawal can consume Stop's last writer slot and disconnect unrelated Gateway sessions. Nested prompts can hang when a matching echo is followed by Idle without an observed Running state, or fail because of updates their result would discard. The Desktop playback cache can delete files it did not create and has no aggregate storage limit.

Took 10 min

Comment thread src/gateway.rs Resolved
Comment thread src/acp_child/capture.rs Resolved
Comment thread src/acp_child/capture.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A repeated ACP Idle snapshot can finish a nested prompt before its work starts. Concurrent Desktop processes can exceed the shared playback cache limit.

Took 10 min

Comment thread src/acp_child/capture.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new Idle gate can strand a nested prompt that ends without text, and a contended playback lock can stall unrelated attachment opens and previews.

Took 6 min 35 sec

Comment thread src/acp_child/capture.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested ACP settlement can retire a session while it is streaming reasoning, or wait indefinitely after a receipt whose matching echo never arrives. Cancelling the latter can disconnect forked siblings.

Took 7 min 51 sec

Comment thread src/acp_child.rs Resolved
Comment thread src/acp_child.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two distinct prompt-capture bugs can falsely quarantine a nested session: an earlier Idle deadline survives explicit foreground activation, and whole-message ACP v2 reasoning is not recognized as progress.

Took 7 min 28 sec

Comment thread src/acp_child/capture.rs Resolved
Comment thread src/acp_child.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A metadata-only ACP v2 thought update can remove the settlement deadline for an answerless nested prompt. Require usable thought content before clearing that deadline.

Took 14 min

Comment thread src/acp_child.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One P2 finding: a content-free answer patch can make the nested prompt return the previous turn’s stop reason before the new turn starts.

Took 5 min 38 sec

Comment thread src/acp_child/capture.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One P2 finding: empty v2 answer text can let a stale Idle snapshot terminate a nested prompt before the real answer arrives.

Took 4 min 53 sec

Comment thread src/acp_child/capture.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An ACP v2 thought chunk missing its required message ID can clear the nested prompt’s Idle deadline and leave the prompt waiting indefinitely.

Took 5 min 40 sec

Comment thread src/acp_child.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A payload-free ACP v2 thought extension can clear the nested prompt’s only settlement deadline.

Took 4 min 28 sec

Comment thread src/acp_child/capture.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nested prompt can lose part of its answer and report a previous turn’s refusal when a stale Idle snapshot arrives after answer streaming begins.

Took 5 min 38 sec

Comment thread src/acp_child/capture.rs
Comment on lines +341 to +343
if repeated_idle
&& !self.current.answer_observed
&& self.current.turn.foreground == Foreground::Waiting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Keep stale Idle from truncating a streaming nested answer

For a child that omits the active snapshot, the first nonempty answer chunk sets answer_observed without changing the foreground from Waiting. A subsequent repeated Idle then skips this guard and settles the correlated prompt immediately. If that snapshot repeats the previous turn’s refusal, prompt_outcome reports a refusal and capture drops the rest of the answer, even if the real Idle(end_turn) is next. ACP v2 allows repeated snapshots to carry the previous stop reason and says not to count them as fresh completions. Treat an Idle after answer progress as provisional when no foreground transition was observed: allow subsequent output to invalidate it, and use bounded confirmation so a genuine final Idle from a peer that omits Running can still settle. Simply removing the answer check would regress that supported case.

Suggested test (simplified):

peer.seed_idle(Refusal);
peer.script_next([
    Receipt(id), Echo(id), AnswerChunk("first "), Idle(Refusal),
    AnswerChunk("second"), Idle(EndTurn),
]);
let result = child.prompt(session, "next", cancel()).await.unwrap();
assert_eq!(result.text, "first second");
For agents:
Validate the following issue, address if needed:

<comment>Keep Idle provisional after answer progress when Running was omitted, and verify that a stale refusal between answer chunks does not discard the full answer.</comment>
<file_context>
@@ -0,0 +339,14 @@
+        // An echo only establishes insertion. A repeated Idle carries no turn
+        // identifier, and even its stop reason may be from an earlier turn.
+        if repeated_idle
+            && !self.current.answer_observed
+            && self.current.turn.foreground == Foreground::Waiting
+        {
+            if (self.matched || !self.current.echoes.is_empty())
+                && self.current.unverified_idle.is_none()
+            {
+                self.current.unverified_idle = Some(Instant::now());
+                return self.matched || newly_unverified;
+            }
+            return newly_unverified;
+        }
</file_context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant