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
description: "Mechanisms for request cancellation"
4
+
---
5
+
6
+
ACP uses JSON-RPC 2.0 for making requests and getting responses.
7
+
8
+
The JSON-RPC specification doesn't define any standard mechanism for request cancellation and keeps it up to the implementation.
9
+
10
+
- The agent and the client **MUST** implement [$/cancelRequest](./schema#%24%2Fcancelrequest) notification method to support per-request cancellation.
11
+
12
+
- When a cancellation request is received from the remote side, the corresponding request activity and all nested activities (including outgoing requests) **MUST** be cancelled, then one of the responses **MUST** be sent back:
13
+
14
+
* an error response with the Cancelled [error code `-32800`](./schema#param-code)
15
+
* a valid response with the appropriate data (e.g., a partial result or a valid result with the Cancelled marker)
16
+
17
+
- The calling side **MAY** implement graceful cancellation processing by waiting for the cancelled response (error code `-32800`) from the remote side.
18
+
19
+
- The request **MAY** be also cancelled from inside the request handler activity (e.g. when a heavy action is being performed in IDE by a request and the user cancels it explicitly). In this case the response with the [error code `-32800`](./schema#param-code) and the appropriate message **MUST** be sent back and the cancellation **SHOULD** be propagated on the calling side.
20
+
21
+
- Cancellation **MAY** also be done explicitly on a per-feature basis to cover the bigger scope of things to cancel (e.g., cancellation of a [prompt turn](./prompt-turn#cancellation))
This member is required. It must be the same as the value of the id member in the request object.
41
+
</ResponseField>
42
+
<ResponseFieldname="result"type={"any"}>
43
+
This member is required on success. This member must not exist if there was an error invoking the method. The value is determined by the method invoked on the server.
A primitive or structured value that contains additional information about the error. This may be omitted.
76
+
</ResponseField>
77
+
78
+
### <spanclass="font-mono">Notification</span>
79
+
80
+
A notification is a request object without an "id" member. Notifications express a lack of interest in the corresponding response and as such no response needs to be returned.
Copy file name to clipboardExpand all lines: schema/schema.json
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,16 @@
1
1
{
2
2
"$defs": {
3
+
"CancelNotification": {
4
+
"description": "Parameter type for JsonRPC cancellation method `$/cancelRequest`.\n\nA request that got canceled still needs send a response with cancellation signal back. It can not be left open / hanging.",
5
+
"properties": {
6
+
"id": {
7
+
"description": "ID of JsonRPC request to cancel",
8
+
"type": "integer"
9
+
}
10
+
},
11
+
"type": "object",
12
+
"x-method": "$/cancelRequest"
13
+
},
3
14
"AgentCapabilities": {
4
15
"description": "Capabilities supported by the agent.\n\nAdvertised during initialization to inform the client about\navailable features and content types.\n\nSee protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/initialization#agent-capabilities)",
0 commit comments