Skip to content

Commit aa0629a

Browse files
committed
Replace keepalive with TTL; add createdAt
1 parent b9a9ac4 commit aa0629a

File tree

4 files changed

+84
-57
lines changed

4 files changed

+84
-57
lines changed

docs/specification/draft/basic/utilities/tasks.mdx

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Task-augmented requests follow a two-phase response pattern that differs from no
9090
- **Normal requests**: The server processes the request and returns the actual operation result directly.
9191
- **Task-augmented requests**: The server accepts the request and immediately returns a `CreateTaskResult` containing task metadata. The actual operation result becomes available later through `tasks/result` after the task completes.
9292

93-
To create a task, requestors send a request with the `modelcontextprotocol.io/task` key included in `_meta`. Requestors **MAY** include a `keepAlive` value representing how long after completion the requestor would like the task results to be kept for.
93+
To create a task, requestors send a request with the `modelcontextprotocol.io/task` key included in `_meta`. Requestors **MAY** include a `ttl` value representing how long from task creation the requestor would like the task to be retained for.
9494

9595
**Request:**
9696

@@ -106,7 +106,7 @@ To create a task, requestors send a request with the `modelcontextprotocol.io/ta
106106
},
107107
"_meta": {
108108
"modelcontextprotocol.io/task": {
109-
"keepAlive": 60000
109+
"ttl": 60000
110110
}
111111
}
112112
}
@@ -123,7 +123,8 @@ To create a task, requestors send a request with the `modelcontextprotocol.io/ta
123123
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
124124
"status": "working",
125125
"statusMessage": "The operation is now in progress.",
126-
"keepAlive": 60000,
126+
"createdAt": "2025-11-25T10:30:00Z",
127+
"ttl": 60000,
127128
"pollInterval": 5000,
128129
"_meta": {
129130
"modelcontextprotocol.io/related-task": {
@@ -161,10 +162,11 @@ To retrieve the state of a task, requestors send a `tasks/get` request:
161162
"id": 3,
162163
"result": {
163164
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
164-
"keepAlive": 30000,
165-
"pollInterval": 5000,
166165
"status": "working",
167166
"statusMessage": "The operation is now in progress.",
167+
"createdAt": "2025-11-25T10:30:00Z",
168+
"ttl": 30000,
169+
"pollInterval": 5000,
168170
"_meta": {
169171
"modelcontextprotocol.io/related-task": {
170172
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840"
@@ -300,13 +302,15 @@ To retrieve a list of tasks, requestors send a `tasks/list` request. This operat
300302
{
301303
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
302304
"status": "working",
303-
"keepAlive": 30000,
305+
"createdAt": "2025-11-25T10:30:00Z",
306+
"ttl": 30000,
304307
"pollInterval": 5000
305308
},
306309
{
307310
"taskId": "abc123-def456-ghi789",
308311
"status": "completed",
309-
"keepAlive": 60000
312+
"createdAt": "2025-11-25T09:15:00Z",
313+
"ttl": 60000
310314
}
311315
],
312316
"nextCursor": "next-page-cursor"
@@ -434,11 +438,12 @@ stateDiagram-v2
434438
1. When the requestor encounters the `input_required` status, it **SHOULD** call `tasks/result` prematurely.
435439
1. When the receiver receives all required input, the task **SHOULD** transition out of `input_required` status (typically back to `working`).
436440

437-
### Keep-Alive and Resource Management
441+
### TTL and Resource Management
438442

439-
1. Receivers **MAY** override the requested `keepAlive` duration.
440-
1. Receivers **MUST** include the actual `keepAlive` duration (or `null` for unlimited) in `tasks/get` responses.
441-
1. After a task reaches a terminal status (`completed`, `failed`, or `cancelled`) and its `keepAlive` duration has elapsed, receivers **MAY** delete the task and its results.
443+
1. Receivers **MUST** include a `createdAt` timestamp (ISO 8601 format) in all task responses to indicate when the task was created.
444+
1. Receivers **MAY** override the requested `ttl` duration.
445+
1. Receivers **MUST** include the actual `ttl` duration (or `null` for unlimited) in `tasks/get` responses.
446+
1. After a task's `ttl` duration has elapsed from creation, receivers **MAY** delete the task and its results, regardless of the task's status.
442447
1. Receivers **MAY** include a `pollInterval` value (in milliseconds) in `tasks/get` responses to suggest polling intervals. Requestors **SHOULD** respect this value when provided.
443448

444449
### Result Retrieval
@@ -471,8 +476,8 @@ Task-augmented requests support progress notifications as defined in the progres
471476
1. Upon receiving a valid cancellation request, receivers **SHOULD** attempt to stop the task's execution (best effort) and **MUST** transition the task to `cancelled` status before sending the response.
472477
1. Once a task is cancelled, it **MUST** remain in `cancelled` status even if execution continues to completion or fails.
473478
1. If the `delete` parameter is `true`, receivers **SHOULD** delete the task and all associated results and metadata after transitioning to `cancelled` status. Receivers **MAY** choose not to support deletion and ignore this parameter.
474-
1. If the `delete` parameter is `false` or omitted, receivers **MUST** retain the task in `cancelled` status subject to the `keepAlive` duration.
475-
1. Requestors **SHOULD** use the `delete` parameter to clean up tasks containing sensitive data promptly rather than relying solely on `keepAlive` expiration.
479+
1. If the `delete` parameter is `false` or omitted, receivers **MUST** retain the task in `cancelled` status subject to the `ttl` duration.
480+
1. Requestors **SHOULD** use the `delete` parameter to clean up tasks containing sensitive data promptly rather than relying solely on `ttl` expiration.
476481

477482
## Message Flow
478483

@@ -483,8 +488,8 @@ sequenceDiagram
483488
participant C as Client (Requestor)
484489
participant S as Server (Receiver)
485490
Note over C,S: 1. Task Creation
486-
C->>S: Request with task metadata (taskId, keepAlive)
487-
S->>C: CreateTaskResult (taskId, status: working, keepAlive, pollInterval)
491+
C->>S: Request with task metadata (taskId, ttl)
492+
S->>C: CreateTaskResult (taskId, status: working, ttl, pollInterval)
488493
S--)C: notifications/tasks/created
489494
Note over C,S: 2. Task Polling
490495
C->>S: tasks/get (taskId)
@@ -499,7 +504,7 @@ sequenceDiagram
499504
C->>S: tasks/result (taskId)
500505
S->>C: Result content
501506
Note over C,S: 4. Cleanup
502-
Note over S: After keepAlive period, task is cleaned up
507+
Note over S: After ttl period from creation, task is cleaned up
503508
```
504509

505510
### Task-Augmented Tool Call With Elicitation
@@ -515,7 +520,7 @@ sequenceDiagram
515520
LLM->>C: Request operation
516521
517522
Note over C,S: Client augments with task metadata
518-
C->>S: tools/call (task-123, keepAlive: 3600000)
523+
C->>S: tools/call (task-123, ttl: 3600000)
519524
S->>C: CreateTaskResult (task-123, status: working)
520525
S--)C: notifications/tasks/created
521526
@@ -557,7 +562,7 @@ sequenceDiagram
557562
S->>C: Result content
558563
C->>LLM: Process result
559564
560-
Note over S: Results retained for keepAlive period
565+
Note over S: Results retained for ttl period from creation
561566
```
562567

563568
### Task-Augmented Sampling Request
@@ -572,7 +577,7 @@ sequenceDiagram
572577
Note over S: Server decides to initiate request
573578
574579
Note over S,C: Server requests client operation (task-augmented)
575-
S->>C: sampling/createMessage (request-789, keepAlive: 3600000)
580+
S->>C: sampling/createMessage (request-789, ttl: 3600000)
576581
C->>S: CreateTaskResult (request-789, status: working)
577582
C--)S: notifications/tasks/created
578583
@@ -604,7 +609,7 @@ sequenceDiagram
604609
605610
Note over S: Server continues processing
606611
607-
Note over C: Results retained for keepAlive period
612+
Note over C: Results retained for ttl period from creation
608613
```
609614

610615
### Task Cancellation Flow
@@ -634,7 +639,7 @@ sequenceDiagram
634639
635640
Note over C: Client receives confirmation
636641
637-
Note over S: After keepAlive period, task cleaned up
642+
Note over S: After ttl period from creation, task cleaned up
638643
```
639644

640645
### Task Cancellation with Deletion Flow
@@ -677,9 +682,10 @@ sequenceDiagram
677682
A task represents the execution state of a request. The task metadata includes:
678683

679684
- `taskId`: Unique identifier for the task
680-
- `keepAlive`: Time in milliseconds that results will be kept available after completion
681-
- `pollInterval`: Suggested time in milliseconds between status checks
682685
- `status`: Current state of the task execution
686+
- `createdAt`: ISO 8601 timestamp when the task was created
687+
- `ttl`: Time in milliseconds from creation before task may be deleted
688+
- `pollInterval`: Suggested time in milliseconds between status checks
683689

684690
### Task Status
685691

@@ -698,14 +704,14 @@ When augmenting a request with task execution, the `modelcontextprotocol.io/task
698704
```json
699705
{
700706
"modelcontextprotocol.io/task": {
701-
"keepAlive": 60000
707+
"ttl": 60000
702708
}
703709
}
704710
```
705711

706712
Fields:
707713

708-
- `keepAlive` (number, optional): Requested duration in milliseconds to retain results after completion
714+
- `ttl` (number, optional): Requested duration in milliseconds to retain task from creation
709715

710716
### Related Task Metadata
711717

@@ -812,9 +818,10 @@ When the underlying request does not complete successfully, the task moves to th
812818
"jsonrpc": "2.0",
813819
"id": 4,
814820
"result": {
815-
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
821+
"taskId": "786512e2-9e0d-44bd-8f29-789f820fe840",
816822
"status": "failed",
817-
"keepAlive": 30000,
823+
"createdAt": "2025-11-25T10:30:00Z",
824+
"ttl": 30000,
818825
"error": "Tool execution failed: API rate limit exceeded"
819826
}
820827
}
@@ -847,16 +854,16 @@ The `tasks/result` endpoint returns exactly what the underlying request would ha
847854

848855
<Warning>
849856

850-
Task results may persist longer than the original request execution time. For sensitive operations, requestors should carefully consider the security implications of extended result retention and may want to retrieve results promptly and request shorter `keepAlive` durations. Requestors are encouraged to use `tasks/cancel` with the `delete` parameter set to `true` to explicitly clean up tasks containing sensitive data rather than relying solely on `keepAlive` expiration.
857+
Task results may persist for the duration specified by the TTL. For sensitive operations, requestors should carefully consider the security implications of extended task retention and may want to retrieve results promptly and request shorter `ttl` durations. Requestors are encouraged to use `tasks/cancel` with the `delete` parameter set to `true` to explicitly clean up tasks containing sensitive data rather than relying solely on `ttl` expiration.
851858

852859
</Warning>
853860

854861
1. Receivers **SHOULD**:
855862
1. Enforce limits on concurrent tasks per requestor
856-
1. Enforce maximum `keepAlive` durations to prevent indefinite resource retention
863+
1. Enforce maximum `ttl` durations to prevent indefinite resource retention
857864
1. Clean up expired tasks promptly to free resources
858865
1. Receivers **SHOULD**:
859-
1. Document maximum supported `keepAlive` duration
866+
1. Document maximum supported `ttl` duration
860867
1. Document maximum concurrent tasks per requestor
861868
1. Implement monitoring and alerting for resource usage
862869

0 commit comments

Comments
 (0)