Skip to content

fix(acp): stop the v2 examples from cancelling a child session - #510

Merged
benbrandt merged 1 commit into
mainfrom
fix/v2-reference-agent-conformance
Nov 19, 2026
Merged

benbrandt merged 1 commit into
mainfrom
fix/v2-reference-agent-conformance

Conversation

@benbrandt

@benbrandt benbrandt commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Problem

v2_one_shot_client and the cookbook's v2 recipe decline permission requests. When a request offers no reject_once option, they sent session/cancel for the session the request named and then answered cancelled.

A request can come from a child session that the agent announced with subagent_update. A client may send session/cancel for a child only while that child advertises capabilities.cancel, and neither example tracks children. So the examples could send a method the spec does not allow for that session.

Change

  • Examples. v2_one_shot_client and the cookbook recipe answer such a request with the cancelled outcome and no longer send session/cancel. The agent must not proceed after cancelled, so the request is still declined. The example no longer stops the turn in that case.
  • Docs. The book gains the v2 rules that fix(acp): align v2 cancellation and session setup with the protocol #509 did not cover:
    • A resume response must carry the session's configOptions and commands. The text said "should", which disagreed with the rule fix(acp): align v2 cancellation and session setup with the protocol #509 added.
    • 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. Treat -32002 from session/delete as success.
    • A permission request or elicitation can name a child session. A session's cost includes its descendants', so clients do not add a child's cost to an ancestor's.
    • md/testy.md says that Testy rejects a systemPrompt with -32602 and does not implement the cancel requests, which get -32601.
    • The coordination example's limitations name that it drops child-session updates.
  • Rustdoc. ActiveSession::send_prompt says to match the inserted user message by the response's message_id, never by content.

This PR originally also changed the cancel error codes and systemPrompt handling in Testy and simple_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, and cargo clippy --all-targets --all-features pass locally.
  • The cookbook doctests, which compile the changed recipe, and the Testy v2 tests pass.
  • Rustdoc with -D warnings passes for agent-client-protocol and the cookbook.

The full just test and the mdbook build were not rerun locally after the rebase.

@benbrandt
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
benbrandt force-pushed the fix/v2-reference-agent-conformance branch from 16e9e3f to abdd3e8 Compare November 19, 2026 08:23
@benbrandt benbrandt changed the title fix(acp): follow the v2 spec's post-1.19 rules in Testy and the examples fix(acp): stop the v2 examples from cancelling a child session Nov 19, 2026
@benbrandt
benbrandt disabled auto-merge November 19, 2026 08:33
@benbrandt
benbrandt enabled auto-merge (squash) November 19, 2026 08:33
@benbrandt
benbrandt merged commit 8d91a29 into main Nov 19, 2026
13 checks passed
@benbrandt
benbrandt deleted the fix/v2-reference-agent-conformance branch November 19, 2026 08:34
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