feat: multi-round-trip request implementation (SEP-2322) (#950)
### Context
Design (`design/mrtr.md`) and implementation proposal for Multi
Round-Trip Requests (MRTR) per
[SEP-2322](de6d76fba3/seps/2322-MRTR.md).
### Changes
- Introduce `InputRequest` and `InputResponse` sealed interfaces with
corresponding `InputRequestMap` and `InputResponseMap` types for custom
map JSON codec implementation.
- Extend `CallToolParams`, `GetPromptParams`, and `ReadResourceParams`
with `InputResponses`, `RequestState` and an unexported `resultType`
("complete" or "input_required") for retry round-trips. The type is set
by the SDK based on input requests presence.
- Add client-side MRTR middleware enabled by default that automatically
fulfills input requests and retries.
- Added MRTROptions on ClientOptions to allow disabling the middleware
and configuring the number of retries.
- Add server-side MRTR middleware for backward compatibility:
transparently bridges input requests to direct
Elicit/CreateMessage/ListRoots calls for older clients
This commit is contained in:
parent
2d47cc9664
commit
189a85ad92
1 changed files with 1587 additions and 23 deletions
|
|
@ -24,6 +24,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
"github.com/modelcontextprotocol/go-sdk/internal/jsonrpc2"
|
||||
"github.com/modelcontextprotocol/go-sdk/jsonrpc"
|
||||
|
|
@ -206,7 +207,7 @@ func TestEndToEnd(t *testing.T) {
|
|||
Role: "user",
|
||||
}},
|
||||
}
|
||||
if diff := cmp.Diff(wantReview, gotReview); diff != "" {
|
||||
if diff := cmp.Diff(wantReview, gotReview, ctrCmpOpts...); diff != "" {
|
||||
t.Errorf("prompts/get 'code_review' mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
|
|
@ -2371,4 +2372,4 @@ func TestSetErrorPreservesContent(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
var ctrCmpOpts = []cmp.Option{cmp.AllowUnexported(CallToolResult{})}
|
||||
var ctrCmpOpts = []cmp.Option{cmpopts.IgnoreUnexported(CallToolResult{}, GetPromptResult{}, ReadResourceResult{})}
|
||||
|
|
|
|||
Loading…
Reference in a new issue