File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -117,11 +117,17 @@ func (s *Server) RemovePrompts(names ...string) {
117117}
118118
119119// AddTool adds a [Tool] to the server, or replaces one with the same name.
120- // The tool's input schema must be non-nil.
121120// The Tool argument must not be modified after this call.
121+ //
122+ // The tool's input schema must be non-nil. For a tool that takes no input,
123+ // or one where any input is valid, set [Tool.InputSchema] to the empty schema,
124+ // &jsonschema.Schema{}.
122125func (s * Server ) AddTool (t * Tool , h ToolHandler ) {
123- // TODO(jba): This is a breaking behavior change. Add before v0.2.0?
124126 if t .InputSchema == nil {
127+ // This prevents the tool author from forgetting to write a schema where
128+ // one should be provided. If we papered over this by supplying the empty
129+ // schema, then every input would be validated and the problem wouldn't be
130+ // discovered until runtime, when the LLM sent bad data.
125131 panic (fmt .Sprintf ("adding tool %q: nil input schema" , t .Name ))
126132 }
127133 if err := addToolErr (s , t , h ); err != nil {
You can’t perform that action at this time.
0 commit comments