fix: return nil for empty tools slice to handle omitzero properly (#861)
The `anthropic.MessageNewParams` uses omitzero tag, but an empty slice is not
considered zero value. Return `nil` instead of empty slice when no tools are
provided to ensure proper omitzero behavior.
commit472889c3bd0a65ed6e18a1031228b5b8fdf32508
author林玮 (Jade Lin) <linw1995@icloud.com>
dateFri 22 Aug 2025, 21:59 (1 year ago)
parent786286f
internal/llm/provider/anthropic.go+3
@@ -169,6 +169,9 @@ func (a *anthropicClient) convertMessages(messages []message.Message) (anthropic
169169}
170170
171171func (a *anthropicClient) convertTools(tools []tools.BaseTool) []anthropic.ToolUnionParam {
172+ if len(tools) == 0 {
173+ return nil
174+ }
172175 anthropicTools := make([]anthropic.ToolUnionParam, len(tools))
173176
174177 for i, tool := range tools {