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
Copy file name to clipboardExpand all lines: docs/specification/draft/basic/utilities/tasks.mdx
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -399,10 +399,10 @@ stateDiagram-v2
399
399
400
400
### Input Required Status
401
401
402
-
1. When a receiver sends a request associated with a task (e.g., elicitation, sampling), the receiver **SHOULD** move the task to the `input_required` status.
402
+
1. When the task receiver has messages for the requestor that are necessary to complete the task, the receiver **SHOULD** move the task to the `input_required` status.
403
403
1. The receiver **MUST** include the `modelcontextprotocol.io/related-task` metadata in the request to associate it with the task.
404
-
1. When the receiver receives all required responses, the task **MAY**transition out of `input_required` status (typically back to `working`).
405
-
1.If multiple related requests are pending, the task **SHOULD**remain in `input_required` status until all are resolved.
404
+
1. When the requestor encounters the `input_required` status, it **SHOULD**call `tasks/result` prematurely.
405
+
1.When the receiver receives all required input, the task **SHOULD**transition out of `input_required` status (typically back to `working`).
406
406
407
407
### Keep-Alive and Resource Management
408
408
@@ -414,8 +414,9 @@ stateDiagram-v2
414
414
### Result Retrieval
415
415
416
416
1. Receivers that accept a task-augmented request **MUST** return a `CreateTaskResult` as the response. This result **SHOULD** be returned as soon as possible after accepting the task.
417
-
1. When a receiver receives a `tasks/result` request, it **MUST** block the response until the task reaches a terminal status (`completed`, `failed`, `cancelled`, or `unknown`).
418
-
1. Receivers **MUST** return from `tasks/result` exactly what the underlying request would have returned, whether that is a successful result or a JSON-RPC error.
417
+
1. When a receiver receives a `tasks/result` request for a task in a terminal status (`completed`, `failed`, `cancelled`, or `unknown`), it **MUST** return the final result of the underlying request, whether that is a successful result or a JSON-RPC error.
418
+
1. When a receiver receives a `tasks/result` request for a task in any other non-terminal status (`submitted`, `working`, `input_required`), it **MUST** block the response until the task reaches a terminal status.
419
+
1. For tasks in a terminal status, receivers **MUST** return from `tasks/result` exactly what the underlying request would have returned, whether that is a successful result or a JSON-RPC error.
419
420
420
421
### Associating Task-Related Messages
421
422
@@ -425,11 +426,11 @@ stateDiagram-v2
425
426
426
427
### Task Cancellation
427
428
429
+
1. Requestors **MAY** send `notifications/cancelled` at any time during task execution.
428
430
1. When a receiver receives a `notifications/cancelled` notification for the JSON-RPC request ID of a task-augmented request, the receiver **SHOULD** immediately move the task to the `cancelled` status and cease all processing associated with that task.
429
431
1. Due to the asynchronous nature of notifications, receivers **MAY** not cancel task processing instantaneously. Receivers **SHOULD** make a best-effort attempt to halt execution as quickly as possible.
430
432
1. If a `notifications/cancelled` notification arrives after a task has already reached a terminal status (`completed`, `failed`, `cancelled`, or `unknown`), receivers **SHOULD** ignore the notification.
431
433
1. After a task reaches `cancelled` status and its `keepAlive` duration has elapsed, receivers **MAY** delete the task and its metadata.
432
-
1. Requestors **MAY** send `notifications/cancelled` at any time during task execution, including when the task is in `input_required` status. If a task is cancelled while in `input_required` status, receivers **SHOULD** also disregard any pending responses to associated requests.
433
434
1. Because notifications do not provide confirmation of receipt, requestors **SHOULD** continue to poll with `tasks/get` after sending a cancellation notification to confirm the task has transitioned to `cancelled` status. If the task does not transition to `cancelled` within a reasonable timeframe, requestors **MAY** assume the cancellation was not processed.
434
435
435
436
### Task Listing
@@ -501,15 +502,15 @@ sequenceDiagram
501
502
C->>S: tasks/get (task-123)
502
503
S->>C: working
503
504
504
-
Note over S: Server requires additional information<br/>Task moves to input_required
505
+
Note over S: Server needs information from client<br/>Task moves to input_required
505
506
506
-
Note over S,C: Server sends elicitation request
507
-
S->>C: elicitation/create (task-123)
508
-
509
-
Note over C,S: Client polls and sees task waiting for input
507
+
Note over C,S: Client polls and discovers input_required
510
508
C->>S: tasks/get (task-123)
511
509
S->>C: input_required
512
510
511
+
Note over C,S: Client receives input requests
512
+
C->>S: tasks/result (task-123)
513
+
S->>C: elicitation/create (task-123)
513
514
C->>U: Prompt user for input
514
515
U->>C: Provide information
515
516
C->>S: elicitation response (task-123)
@@ -660,7 +661,7 @@ Tasks can be in one of the following states:
660
661
661
662
-`submitted`: The request has been received and queued for execution
662
663
-`working`: The request is currently being processed
663
-
-`input_required`: The request is waiting on additional input from the requestor
664
+
-`input_required`: The receiver needs input from the requestor. The requestor should call `tasks/result` to receive input requests, even though the task has not reached a terminal state.
664
665
-`completed`: The request completed successfully and results are available
665
666
-`failed`: The associated request did not complete successfully. For tool calls specifically, this includes cases where the tool call result has `isError` set to true.
666
667
-`cancelled`: The request was cancelled before completion
0 commit comments