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-24Lines changed: 13 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,7 +121,7 @@ To create a task, requestors send a request with the `modelcontextprotocol.io/ta
121
121
"id": 1,
122
122
"result": {
123
123
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
124
-
"status": "submitted",
124
+
"status": "working",
125
125
"keepAlive": 60000,
126
126
"pollInterval": 5000,
127
127
"_meta": {
@@ -162,7 +162,7 @@ To retrieve the state of a task, requestors send a `tasks/get` request:
162
162
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
163
163
"keepAlive": 30000,
164
164
"pollInterval": 5000,
165
-
"status": "submitted",
165
+
"status": "working",
166
166
"_meta": {
167
167
"modelcontextprotocol.io/related-task": {
168
168
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840"
@@ -362,23 +362,17 @@ These requirements apply to all parties that support receiving task-augmented re
362
362
363
363
### Task Status Lifecycle
364
364
365
-
1. Tasks **MUST** begin in the `submitted` status when created.
365
+
1. Tasks **MUST** begin in the `working` status when created.
366
366
1. Receivers **MUST** only transition tasks through the following valid paths:
367
-
1. From `submitted`: may move to `working`, `input_required`, `completed`, `failed`, `cancelled`, or `unknown`
368
-
1. From `working`: may move to `input_required`, `completed`, `failed`, `cancelled`, or `unknown`
369
-
1. From `input_required`: may move to `working`, `completed`, `failed`, `cancelled`, or `unknown`
370
-
1. Tasks in `completed`, `failed`, `cancelled`, or `unknown` status **MUST NOT** transition to any other status (terminal states)
371
-
1. Receivers **MAY** move directly from `submitted` to `completed` if execution completes immediately.
372
-
1. The `unknown` status is a terminal fallback state for unexpected error conditions. Receivers **SHOULD** use `failed` with an error message instead when possible.
367
+
1. From `working`: may move to `input_required`, `completed`, `failed`, or `cancelled`
368
+
1. From `input_required`: may move to `working`, `completed`, `failed`, or `cancelled`
369
+
1. Tasks in `completed`, `failed`, or `cancelled` status **MUST NOT** transition to any other status (terminal states)
373
370
374
371
**Task Status State Diagram:**
375
372
376
373
```mermaid
377
374
stateDiagram-v2
378
-
[*] --> submitted
379
-
380
-
submitted --> working
381
-
submitted --> terminal
375
+
[*] --> working
382
376
383
377
working --> input_required
384
378
working --> terminal
@@ -393,7 +387,6 @@ stateDiagram-v2
393
387
• completed
394
388
• failed
395
389
• cancelled
396
-
• unknown
397
390
end note
398
391
```
399
392
@@ -414,8 +407,8 @@ stateDiagram-v2
414
407
### Result Retrieval
415
408
416
409
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 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.
410
+
1. When a receiver receives a `tasks/result` request for a task in a terminal status (`completed`, `failed`, or `cancelled`), it **MUST** return the final result of the underlying request, whether that is a successful result or a JSON-RPC error.
411
+
1. When a receiver receives a `tasks/result` request for a task in any other non-terminal status (`working` or`input_required`), it **MUST** block the response until the task reaches a terminal status.
419
412
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.
420
413
421
414
### Associating Task-Related Messages
@@ -429,7 +422,7 @@ stateDiagram-v2
429
422
1. Requestors **MAY** send `notifications/cancelled` at any time during task execution.
430
423
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.
431
424
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.
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.
425
+
1. If a `notifications/cancelled` notification arrives after a task has already reached a terminal status (`completed`, `failed`, or `cancelled`), receivers **SHOULD** ignore the notification.
433
426
1. After a task reaches `cancelled` status and its `keepAlive` duration has elapsed, receivers **MAY** delete the task and its metadata.
434
427
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.
435
428
@@ -457,12 +450,10 @@ sequenceDiagram
457
450
participant S as Server (Receiver)
458
451
Note over C,S: 1. Task Creation
459
452
C->>S: Request with task metadata (taskId, keepAlive)
Note over S: Server continues processing<br/>while waiting for result
@@ -659,13 +650,11 @@ A task represents the execution state of a request. The task metadata includes:
659
650
660
651
Tasks can be in one of the following states:
661
652
662
-
-`submitted`: The request has been received and queued for execution
663
653
-`working`: The request is currently being processed
664
654
-`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.
665
655
-`completed`: The request completed successfully and results are available
666
656
-`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.
667
657
-`cancelled`: The request was cancelled before completion
668
-
-`unknown`: A terminal fallback state for unexpected error conditions when the receiver cannot determine the actual task state
|"submitted"// The request has been received and queued for execution
1164
1163
|"working"// The request is currently being processed
1165
1164
|"input_required"// The task is waiting for input (e.g., elicitation or sampling)
1166
1165
|"completed"// The request completed successfully and results are available
1167
1166
|"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.
1168
-
|"cancelled"// The request was cancelled before completion
1169
-
|"unknown";// A terminal fallback state for unexpected error conditions
1167
+
|"cancelled";// The request was cancelled before completion
1170
1168
1171
1169
/**
1172
1170
* Metadata for augmenting a request with task execution.
0 commit comments