on main help sign in
fix: return nil for empty tools slice to handle omitzero properly (#861)
472889c林玮 (Jade Lin)
internal/llm/provider/anthropic.go+3
@@ -169,6 +169,9 @@ func (a *anthropicClient) convertMessages(messages []message.Message) (anthropic
169}
169}
170
170
171func (a *anthropicClient) convertTools(tools []tools.BaseTool) []anthropic.ToolUnionParam {
171func (a *anthropicClient) convertTools(tools []tools.BaseTool) []anthropic.ToolUnionParam {
172+ if len(tools) == 0 {
173+ return nil
174+ }
172 anthropicTools := make([]anthropic.ToolUnionParam, len(tools))
175 anthropicTools := make([]anthropic.ToolUnionParam, len(tools))
173
176
174 for i, tool := range tools {
177 for i, tool := range tools {