package llm import "testing" func TestResponseIsEmpty(t *testing.T) { img := ImagePart{MIME: "image/png", Data: []byte{0x89, 0x50, 0x4e, 0x47}} tests := []struct { name string resp *Response want bool }{ {"nil response", nil, true}, {"no parts, no tool calls", &Response{FinishReason: FinishStop}, true}, {"single empty text part", &Response{Parts: []Part{Text("")}}, true}, {"whitespace-only text", &Response{Parts: []Part{Text(" \n\t ")}}, true}, {"real text", &Response{Parts: []Part{Text("hello")}}, false}, {"tool call, no text", &Response{ToolCalls: []ToolCall{{ID: "1", Name: "x"}}}, false}, {"image only", &Response{Parts: []Part{img}}, false}, {"empty text but a tool call", &Response{Parts: []Part{Text("")}, ToolCalls: []ToolCall{{ID: "1", Name: "x"}}}, false}, {"whitespace text plus an image", &Response{Parts: []Part{Text(" "), img}}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := tt.resp.IsEmpty(); got != tt.want { t.Errorf("IsEmpty() = %v, want %v", got, tt.want) } }) } }