Skip to content

feat(v2): make prompt response an insertion receipt (JUNIE-5706) - #142

Merged
EugeneTheDev merged 5 commits into
masterfrom
aefimov/feat/JUNIE-5706-v2-prompt-message-id
Oct 12, 2026
Merged

EugeneTheDev merged 5 commits into
masterfrom
aefimov/feat/JUNIE-5706-v2-prompt-message-id

Conversation

@wayfarer-rus

@wayfarer-rus wayfarer-rus commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • V2 session/prompt now answers with an insertion receipt. PromptResponse has a required messageId, the id of the inserted user message.
  • The V2 agent awaits asynchronously the AgentSession.prompt() flow and replies to session/prompt after the first user_message or user_message_chunk update.
  • ClientSession.prompt() returns the receipt MessageId.
  • Other alpha.7 schema items:
    • DiffPatch uses the "text" wire key in place of "diff" (alpha.3). The Kotlin property name does not change.
    • New ToolCallUpdate.name patch field (alpha.4).
    • availableCommands on the V2 new, resume, and fork session responses (alpha.6), filled from the new AgentSession.availableCommands. An empty list is sent as []. null, a non-array value, and invalid items decode tolerantly.
  • Tests for the protocol primitive, agent, client, and model. README and AGENTS.md notes. Updated acp-model.api and acp.api.

Breaking changes (V2, @UnstableApi)

  • A V2 prompt flow that never emits a user message now fails every prompt.
  • PromptResponse requires messageId. ClientSession.prompt() returns MessageId in place of Unit. Because MessageId is a value class, its JVM name is now prompt-z2_y7hQ.
  • ToolCallUpdate has a new constructor parameter after title. Positional callers must use named arguments.

Protocol source and scope

  • Upstream ACP schema tag schema-v2.0.0-alpha.7.
  • The schema has no error stop reason, so a failure after insertion keeps idle with a null stop reason.
  • Kotlin SDK only. No publishing changes. RequestOutcome.onCompletion has no production user now. Its removal is a separate follow-up.
  • YouTrack: JUNIE-5706. This unblocks JUNIE-5707.

@EugeneTheDev
EugeneTheDev self-requested a review October 8, 2026 13:57

@EugeneTheDev EugeneTheDev left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My major concern here is that you worked around the existing RequestOutcome and created your own setRespondingRequestHandler, which relies on implicit coroutine context variables (something I'm strongly against here). It also introduces a number of bugs, mostly concurrency-related, which the existing implementation using RequestOutcome didn't have.

I also think the number of tests can be reduced to leave only the essential ones.

Comment thread README.md Outdated
Comment thread AGENTS.md Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/protocol/Protocol.kt Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/protocol/Protocol.kt Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/protocol/Protocol.kt Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/agent/v2/Agent.kt Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/agent/v2/Agent.kt
Comment thread README.md Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/protocol/Protocol.kt Outdated
@wayfarer-rus
wayfarer-rus force-pushed the aefimov/feat/JUNIE-5706-v2-prompt-message-id branch from 863703e to abf0f75 Compare October 9, 2026 08:20
wayfarer-rus and others added 3 commits October 9, 2026 10:26
Align v2 with ACP schema tag schema-v2.0.0-alpha.7.

- PromptResponse carries required messageId of the inserted user message
- agent replies after first user_message/user_message_chunk update, via
  new internal Protocol.setRespondingRequestHandler
- failure, completion or cancellation before insertion -> JSON-RPC
  error, no idle update; after insertion turn-closing rules unchanged
- ClientSession.prompt() returns the receipt MessageId
- DiffPatch wire key diff -> text (alpha.3)
- add ToolCallUpdate.name (alpha.4)
- add availableCommands to session new/resume/fork responses, filled
  from new AgentSession.availableCommands (alpha.6)

Breaking for v2 agents: a prompt flow that never emits a user message
fails every prompt. JVM name of ClientSession.prompt becomes
prompt-z2_y7hQ (MessageId value class).

Co-authored-by: Junie <junie@jetbrains.com>
Remove complexity found in an over-engineering review of the insertion
receipt change. Behavior is unchanged, except as noted below.

- Agent: drop the separate "ended before insertion" check. The responding
  request handler already answers a handler that returns without a reply
  with -32603. Merge the three catch blocks of runPrompt into one.
- Protocol: drop the unreachable try/catch after respond. Its only caller
  already handles every failure after insertion.
- Model: share the skip-invalid-item loop as JsonArray.decodeSkippingInvalid.
  Send an empty availableCommands list as [], the same as configOptions.
  Schema v2.0.0-alpha.7 treats an omitted and an empty list the same.
- Tests: share turnUpdates and insertedUserMessage in acp-ktor-test
  utils.kt, reuse scriptedV2Support and sessionUpdate() in AgentTest,
  and remove repeated assertions in SessionResponsesTest.

Co-authored-by: Junie <junie@jetbrains.com>
Use RequestOutcome for the insertion receipt, buffered update delivery, and collector cleanup. Remove setRespondingRequestHandler and the response slot carried through coroutine context.

Reject cancellation before insertion with -32800. Discard buffered updates on pre-insertion failure or rejected receipt delivery. Keep the prompt Flow signature and avoid suspending user flows on batch reply completion.

Cover batch locking, cancellation, callback errors, and rejected receipts. Remove obsolete responding-handler tests and align delivery-order documentation.

Co-authored-by: Junie <junie@jetbrains.com>
@wayfarer-rus
wayfarer-rus force-pushed the aefimov/feat/JUNIE-5706-v2-prompt-message-id branch from abf0f75 to f026a78 Compare October 9, 2026 08:29
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/agent/v2/Agent.kt Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/agent/v2/Agent.kt Outdated
Comment thread AGENTS.md Outdated
Comment thread acp/src/commonMain/kotlin/com/agentclientprotocol/agent/v2/Agent.kt
@EugeneTheDev

Copy link
Copy Markdown
Collaborator

nit: Also, there are now 5 new v2 tests in AgentTest plus a new PromptReceiptTest with 4 tests, and the new class has its own FrameTransport/agent harness. Some scenarios overlap: "ends before inserting" vs failedInsertionDiscardsUpdates…, and "local cancellation fails a prompt before insertion" vs cancelBeforeInsertion…. Could the receipt tests live in one place with one harness, keeping one test per behavior?

…y over the wire and wait for the first user message asyncronously instead
@EugeneTheDev
EugeneTheDev merged commit d4df1ec into master Oct 12, 2026
2 checks passed
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.

2 participants