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 @@ -131,11 +131,17 @@ func (s *Server) RemovePrompts(names ...string) {
131131}
132132
133133// AddTool adds a [Tool] to the server, or replaces one with the same name.
134- // The tool's input schema must be non-nil.
135134// The Tool argument must not be modified after this call.
135+ //
136+ // The tool's input schema must be non-nil. For a tool that takes no input,
137+ // or one where any input is valid, set [Tool.InputSchema] to the empty schema,
138+ // &jsonschema.Schema{}.
136139func (s * Server ) AddTool (t * Tool , h ToolHandler ) {
137- // TODO(jba): This is a breaking behavior change. Add before v0.2.0?
138140 if t .InputSchema == nil {
141+ // This prevents the tool author from forgetting to write a schema where
142+ // one should be provided. If we papered over this by supplying the empty
143+ // schema, then every input would be validated and the problem wouldn't be
144+ // discovered until runtime, when the LLM sent bad data.
139145 panic (fmt .Sprintf ("adding tool %q: nil input schema" , t .Name ))
140146 }
141147 if err := addToolErr (s , t , h ); err != nil {
You can’t perform that action at this time.
0 commit comments