No automatic completion support unless needed #974
+113
−6
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.
Description
isCompletable
function, a runtime type guard to detectCompletable
-wrapped Zod typeshandlePromptCompletion
method,isCompletable
function fromcompletable.ts
setResourceRequestHandlers
methodsetCompletionRequestHandler
- supporting resources does not automatically mean that resource template completion is supportedsetPromptRequestHandlers
methodsetCompletionRequestHandler
- supporting prompts does not automatically mean that prompt argument completion is supported_createRegisteredResourceTemplate
methodsetCompletionRequestHandler
createRegisteredPrompt
methodCompletable
schemasetCompletionRequestHandler
Motivation and Context
@evalstate discovered that when registering a prompt or resource template, it was automatically setting a completion request handler and advertising the
completions
capability. However in order to support completions, at least one argument of a prompt must have aCompletable
schema or one argument of a resource template must have acompleteCallback
.In his case, he was not supporting
completions
on his prompts and resources, and was concerned that clients would send unnecessary completion requests because of this automatic advertisement of completions.This PR checks each registered prompt and resource template, and only does automatic advertisement and listening for completion requests if completable argument is found.
How Has This Been Tested?
Breaking Changes
Nope. Existing behavior for auto-advertisement of completions will still allow completable arguments to be completed. If no completable prompt or resource template arguments exist, then the previous behavior of allowing completion requests was a bug and will now be defeated.
Types of changes
Checklist
Additional context