Add statelessMode to streamableHttp.ts #362
Closed
+0
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Support stateless StreamableHTTP transport. Resolves this issue: #360
Currently, even when configured to return an undefined session ID (sessionIdGenerator: undefined;), Requests still have to be stateful due to the following check:
https://github.com/rinormaloku/typescript-sdk/blob/75078cf549f894b4aaf1d12ce183ab4a31333dea/src/server/streamableHttp.ts#L481-L498
The introduced
statelessMode
property improves the clarity and removes the "side effect" loaded onto sessionIdGenerator.How Has This Been Tested?
Updated unit tests as well as manually, as described below:
Start a server and run the following tool call. It fails with the error shown below:
With this change, the request will complete successfully.
Note: The initialization check is removed from the unit tests in
streamableHttp.test.ts
Breaking Changes
statelessMode
option to true. Alternatively, we can still use the check for sessionIdGenerator being undefined, to set the statelessMode internally (or to simply set initialization to true). However, it would be good to improve this implicit meaning ofsessionIdGenerator
while it is still not widely used.Types of changes
Checklist