Repository navigation
fix(acp): align v2 cancellation and session setup with the protocol - #509
Merged
Merged
Conversation
Use method-not-found for unhandled entity cancellation and reject unsupported system prompts in the example agents. Keep each retry tied to its original held prompt so cancelling any pending attempt settles the same submission.
benbrandt
enabled auto-merge (squash)
November 18, 2026 15:40
benbrandt
disabled auto-merge
November 18, 2026 15:49
benbrandt
enabled auto-merge (squash)
November 18, 2026 15:49
benbrandt
added a commit
that referenced
this pull request
Nov 19, 2026
`v2_one_shot_client` and the cookbook's v2 recipe sent `session/cancel` for the session a permission request named when the request offered no `reject_once` option. A request can come from a child session the agent announced with `subagent_update`, and a client may send `session/cancel` for a child only while it advertises `capabilities.cancel`. Both now answer `cancelled`, which declines the request, and send no `session/cancel`. The book gains the v2 rules that #509 did not cover: - A resume response must carry the session's `configOptions` and commands. The text said "should". - Cancelling any pending request for an `idempotencyKey` withdraws the uninserted prompt, and a key is scoped to its session. - Retry `session/set_config_option` before further changes, and treat `-32002` from `session/delete` as success. - A session's `cost` includes its descendants', so clients do not add a child's cost to an ancestor's. `md/testy.md` now says what Testy does with a `systemPrompt` and with the cancel requests it does not implement.
benbrandt
added a commit
that referenced
this pull request
Nov 19, 2026
`v2_one_shot_client` and the cookbook's v2 recipe sent `session/cancel` for the session a permission request named when the request offered no `reject_once` option. A request can come from a child session the agent announced with `subagent_update`, and a client may send `session/cancel` for a child only while it advertises `capabilities.cancel`. Both now answer `cancelled`, which declines the request, and send no `session/cancel`. The book gains the v2 rules that #509 did not cover: - A resume response must carry the session's `configOptions` and commands. The text said "should". - Cancelling any pending request for an `idempotencyKey` withdraws the uninserted prompt, and a key is scoped to its session. - Retry `session/set_config_option` before further changes, and treat `-32002` from `session/delete` as success. - A session's `cost` includes its descendants', so clients do not add a child's cost to an ancestor's. `md/testy.md` now says what Testy does with a `systemPrompt` and with the cancel requests it does not implement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow the v2 protocol clarifications after the schema 1.19 release:
-32601for unhandledtool_call/cancelandterminal/cancel. An implemented handler distinguishes unknown or inactive sessions (-32002withdata.sessionId) from unknown, final, or non-cancellable items in a known session (-32602).systemPromptvalues with-32602in Testy andsimple_agent_v2, without creating or resuming the session.$/cancel_request, cancelling any pending attempt withdraws that held prompt. Every waiting attempt gets the same outcome, even if a later submission reuses its key.Update the v2 guide and migration notes. No changes to v1 behavior or the published schema.
Testing
just testmdbook buildgit diff --checkandrustfmt --checkon changed Rust files.