Repository navigation
fix(acp): stop the v2 examples from cancelling a child session - #510
Merged
Merged
Conversation
benbrandt
enabled auto-merge (squash)
November 18, 2026 15:51
`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
force-pushed
the
fix/v2-reference-agent-conformance
branch
from
November 19, 2026 08:23
16e9e3f to
abdd3e8
Compare
benbrandt
disabled auto-merge
November 19, 2026 08:33
benbrandt
enabled auto-merge (squash)
November 19, 2026 08:33
This was referenced Nov 19, 2026
Merged
Merged
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.
Problem
v2_one_shot_clientand the cookbook's v2 recipe decline permission requests. When a request offers noreject_onceoption, they sentsession/cancelfor the session the request named and then answeredcancelled.A request can come from a child session that the agent announced with
subagent_update. A client may sendsession/cancelfor a child only while that child advertisescapabilities.cancel, and neither example tracks children. So the examples could send a method the spec does not allow for that session.Change
v2_one_shot_clientand the cookbook recipe answer such a request with thecancelledoutcome and no longer sendsession/cancel. The agent must not proceed aftercancelled, so the request is still declined. The example no longer stops the turn in that case.configOptionsand commands. The text said "should", which disagreed with the rule fix(acp): align v2 cancellation and session setup with the protocol #509 added.idempotencyKeywithdraws the uninserted prompt, and a key is scoped to its session.session/set_config_optionbefore further changes. Treat-32002fromsession/deleteas success.costincludes its descendants', so clients do not add a child's cost to an ancestor's.md/testy.mdsays that Testy rejects asystemPromptwith-32602and does not implement the cancel requests, which get-32601.ActiveSession::send_promptsays to match the inserted user message by the response'smessage_id, never by content.This PR originally also changed the cancel error codes and
systemPrompthandling in Testy andsimple_agent_v2. #509 landed its own version of both, so those parts are dropped and this branch is rebuilt on top of it.Testing
cargo fmt --check,typos, andcargo clippy --all-targets --all-featurespass locally.-D warningspasses foragent-client-protocoland the cookbook.The full
just testand the mdbook build were not rerun locally after the rebase.