Skip to content

Commit 4a95b30

Browse files
committed
SEP-2322: Explicitly support extending ResultType
1 parent 33c3724 commit 4a95b30

8 files changed

Lines changed: 49 additions & 50 deletions

File tree

docs/seps/2322-MRTR.mdx

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/seps/2663-tasks-extension.mdx

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/specification/draft/basic/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ can use to determine how to parse and handle the `result` object.
7979

8080
- A `resultType` of `"complete"` indicates the request completed successfully and the result contains the final content.
8181
- A `resultType` of `"input_required"` indicates the request is incomplete and more information is needed to process the request. The result contains an `InputRequiredResult` object with additional information needed.
82+
- A `resultType` of any value unrecognized by the client **MUST** be considered invalid. This field is open to extension.
8283
- For backward compatibility with servers implementing earlier protocol versions, which do not include `resultType`, clients **MUST** treat an absent `resultType` as `"complete"`.
8384

8485
#### Error Responses

docs/specification/draft/schema.mdx

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/draft/schema.json

Lines changed: 26 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/draft/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export interface Notification {
162162
* input_required - the request requires additional input and the result contains an {@link InputRequiredResult} object with instructions for the client to provide additional input before retrying the original request.
163163
* @category Common Types
164164
*/
165-
export type ResultType = "complete" | "input_required";
165+
export type ResultType = "complete" | "input_required" | string;
166166

167167
/**
168168
* Common result fields.

seps/2322-MRTR.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ export interface InputResponseRequestParams extends RequestParams {
320320
}
321321
```
322322

323-
Since this change creates a polymorphic response for method calls like 'tools/call', we are introducing a new field to `Result` which indicate the `ResultType`. The client should parse this field to determine the type of the Result contained in the message. If this field is not provided the Client should assume a `ResultType` of "complete" for backwards compatibility. The schema change will look like this:
323+
Since this change creates a polymorphic response for method calls like 'tools/call', we are introducing a new field to `Result` which indicate the `ResultType`. The client should parse this field to determine the type of the Result contained in the message, treating unrecognized values as invalid protocol responses. The `ResultType` is open for extensions to introduce additional values. If this field is not provided the Client should assume a `ResultType` of "complete" for backwards compatibility. The schema change will look like this:
324324

325325
```typescript
326326
/**
@@ -337,7 +337,8 @@ export interface Result {
337337

338338
export type ResultType =
339339
| "complete" // the request completed successfully and the result contains the final content.
340-
| "input_required"; // the request is incomplete and the result contains an {@link InputRequiredResult} object
340+
| "input_required" // the request is incomplete and the result contains an {@link InputRequiredResult} object
341+
| string; // open to extensions
341342
```
342343

343344
We anticipate this field will be useful for future extensibility, as it allows us to introduce new types of results and can also apply to `tasks` as well.

seps/2663-tasks-extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ A request that is eligible for task-augmentation may return one of two distinct
122122

123123
```typescript
124124
// "task" is introduced by this extension.
125-
type ResultType = "complete" | "input_required" | "task";
125+
type ResultType = "complete" | "input_required" | "task" | string;
126126
```
127127

128128
Servers **MUST** set `resultType` to `"task"` when returning a `CreateTaskResult` so that clients can distinguish it from a standard result. Servers **MUST NOT** set `resultType` to `"task"` on result types other than `CreateTaskResult`.

0 commit comments

Comments
 (0)