diff --git a/pkg/anthropic/opts.go b/pkg/anthropic/opts.go index b805899..1d11d52 100644 --- a/pkg/anthropic/opts.go +++ b/pkg/anthropic/opts.go @@ -103,16 +103,16 @@ func OptTemperature(v float32) Opt { // Add a tool func OptTool(value ...*schema.Tool) Opt { return func(o *options) error { - // Check tools + // Make a copy of each tool for _, tool := range value { if tool == nil { return ErrBadParameter.With("OptTool") + } else { + tool := *tool + o.Tools = append(o.Tools, &tool) } } - // Append tools - o.Tools = append(o.Tools, value...) - // Return success return nil }