fix: return nil for empty tools slice to handle omitzero properly (#861)

林玮 (Jade Lin) created

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.

Change summary

internal/llm/provider/anthropic.go | 3 +++
1 file changed, 3 insertions(+)

Detailed changes

internal/llm/provider/anthropic.go 🔗

@@ -169,6 +169,9 @@ func (a *anthropicClient) convertMessages(messages []message.Message) (anthropic
 }
 
 func (a *anthropicClient) convertTools(tools []tools.BaseTool) []anthropic.ToolUnionParam {
+	if len(tools) == 0 {
+		return nil
+	}
 	anthropicTools := make([]anthropic.ToolUnionParam, len(tools))
 
 	for i, tool := range tools {