You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(connection): honor $/cancel_request and reply -32800 to cancelled requests
ACP v1 defines the `$/cancel_request` notification (part of the stable v1
schema vendored in schema/, 1.23.0; see
https://agentclientprotocol.com/protocol/v1/cancellation), and the SDK
already ships `PROTOCOL_METHODS["cancel_request"]`, but `Connection` never
handled it:
- An incoming `$/cancel_request` fell through to the router, which logged
an ERROR traceback (method not found) while the targeted handler kept
running and the peer never received the required response.
- A handler that ended with `CancelledError` (cancelled from inside the
agent) produced no response at all, leaving the peer waiting forever.
- Cancelling the task awaiting `send_request` only dropped the local
future; the peer kept working on the request.
- `close()` hung forever when a handler answered its own cancellation with
a result, because the response was queued on an already-closed sender.
`Connection` now tracks in-flight incoming requests by id, cancels the
handler task on `$/cancel_request`, answers cancelled requests with
`-32800 Request cancelled` (a handler may still return a partial result),
sends `$/cancel_request` when a still-pending outgoing request is
cancelled locally, and skips replies once the connection is closed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
0 commit comments