Skip to content

fix(acp): align v2 cancellation and session setup with the protocol - #509

Merged
benbrandt merged 2 commits into
mainfrom
benbrandt/acp-v2-conformance
Nov 18, 2026
Merged

benbrandt merged 2 commits into
mainfrom
benbrandt/acp-v2-conformance

Conversation

@benbrandt

Copy link
Copy Markdown
Member

Summary

Follow the v2 protocol clarifications after the schema 1.19 release:

  • Return -32601 for unhandled tool_call/cancel and terminal/cancel. An implemented handler distinguishes unknown or inactive sessions (-32002 with data.sessionId) from unknown, final, or non-cancellable items in a known session (-32602).
  • Reject unsupported systemPrompt values with -32602 in Testy and simple_agent_v2, without creating or resuming the session.
  • Tie retries to the outcome of the specific held prompt they joined. Where the example agents honor $/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 test
  • mdbook build
  • git diff --check and rustfmt --check on changed Rust files.

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
benbrandt enabled auto-merge (squash) November 18, 2026 15:40
@benbrandt
benbrandt disabled auto-merge November 18, 2026 15:49
@benbrandt
benbrandt enabled auto-merge (squash) November 18, 2026 15:49
@benbrandt
benbrandt merged commit ade2f13 into main Nov 18, 2026
13 checks passed
@benbrandt
benbrandt deleted the benbrandt/acp-v2-conformance branch November 18, 2026 15:51
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.
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