chore: lint

Kujtim Hoxha created

Change summary

agent.go                                |  2 
agent_stream_test.go                    |  2 
agent_test.go                           | 31 +++++++++++++++++++++-----
examples/agent/main.go                  |  1 
examples/streaming-agent-simple/main.go |  1 
examples/streaming-agent/main.go        |  1 
providers/openai.go                     |  3 --
providers/openai_test.go                |  2 
tool_test.go                            |  1 
9 files changed, 28 insertions(+), 16 deletions(-)

Detailed changes

agent.go 🔗

@@ -1002,7 +1002,7 @@ func (a *agent) processStepStream(ctx context.Context, stream StreamResponse, op
 	var stepContent []Content
 	var stepToolCalls []ToolCallContent
 	var stepUsage Usage
-	var stepFinishReason FinishReason = FinishReasonUnknown
+	stepFinishReason := FinishReasonUnknown
 	var stepWarnings []CallWarning
 	var stepProviderMetadata ProviderMetadata
 

agent_stream_test.go 🔗

@@ -565,4 +565,4 @@ func TestStreamingAgentSources(t *testing.T) {
 	// Verify sources are in final result
 	resultSources := result.Response.Content.Sources()
 	require.Equal(t, 2, len(resultSources))
-}
+}

agent_test.go 🔗

@@ -786,6 +786,7 @@ func TestStopConditions(t *testing.T) {
 	}
 
 	t.Run("StepCountIs", func(t *testing.T) {
+		t.Parallel()
 		condition := StepCountIs(2)
 
 		// Should not stop with 1 step
@@ -802,6 +803,7 @@ func TestStopConditions(t *testing.T) {
 	})
 
 	t.Run("HasToolCall", func(t *testing.T) {
+		t.Parallel()
 		condition := HasToolCall("search")
 
 		// Should not stop when tool not called
@@ -822,6 +824,7 @@ func TestStopConditions(t *testing.T) {
 	})
 
 	t.Run("HasContent", func(t *testing.T) {
+		t.Parallel()
 		reasoningCondition := HasContent(ContentTypeReasoning)
 		fileCondition := HasContent(ContentTypeFile)
 
@@ -837,6 +840,7 @@ func TestStopConditions(t *testing.T) {
 	})
 
 	t.Run("FinishReasonIs", func(t *testing.T) {
+		t.Parallel()
 		stopCondition := FinishReasonIs(FinishReasonStop)
 		lengthCondition := FinishReasonIs(FinishReasonLength)
 
@@ -870,6 +874,7 @@ func TestStopConditions_Integration(t *testing.T) {
 	t.Parallel()
 
 	t.Run("StepCountIs integration", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -898,6 +903,7 @@ func TestStopConditions_Integration(t *testing.T) {
 	})
 
 	t.Run("Multiple stop conditions", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -934,6 +940,7 @@ func TestPrepareStep(t *testing.T) {
 	t.Parallel()
 
 	t.Run("System prompt modification", func(t *testing.T) {
+		t.Parallel()
 		var capturedSystemPrompt string
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
@@ -977,6 +984,7 @@ func TestPrepareStep(t *testing.T) {
 	})
 
 	t.Run("Tool choice modification", func(t *testing.T) {
+		t.Parallel()
 		var capturedToolChoice *ToolChoice
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
@@ -1014,6 +1022,7 @@ func TestPrepareStep(t *testing.T) {
 	})
 
 	t.Run("Active tools modification", func(t *testing.T) {
+		t.Parallel()
 		var capturedToolNames []string
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
@@ -1058,6 +1067,7 @@ func TestPrepareStep(t *testing.T) {
 	})
 
 	t.Run("No tools when DisableAllTools is true", func(t *testing.T) {
+		t.Parallel()
 		var capturedToolCount int
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
@@ -1095,6 +1105,7 @@ func TestPrepareStep(t *testing.T) {
 	})
 
 	t.Run("All fields modified together", func(t *testing.T) {
+		t.Parallel()
 		var capturedSystemPrompt string
 		var capturedToolChoice *ToolChoice
 		var capturedToolNames []string
@@ -1158,6 +1169,7 @@ func TestPrepareStep(t *testing.T) {
 	})
 
 	t.Run("Nil fields use parent values", func(t *testing.T) {
+		t.Parallel()
 		var capturedSystemPrompt string
 		var capturedToolChoice *ToolChoice
 		var capturedToolNames []string
@@ -1218,6 +1230,7 @@ func TestPrepareStep(t *testing.T) {
 	})
 
 	t.Run("Empty ActiveTools means all tools", func(t *testing.T) {
+		t.Parallel()
 		var capturedToolNames []string
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
@@ -1265,6 +1278,7 @@ func TestToolCallRepair(t *testing.T) {
 	t.Parallel()
 
 	t.Run("Valid tool call passes validation", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -1305,12 +1319,13 @@ func TestToolCallRepair(t *testing.T) {
 		require.Len(t, result.Steps, 1) // Only one step since FinishReason is stop
 
 		// Check that tool call was executed successfully
-		toolCalls := result.Steps[0].Response.Content.ToolCalls()
+		toolCalls := result.Steps[0].Content.ToolCalls()
 		require.Len(t, toolCalls, 1)
 		require.False(t, toolCalls[0].Invalid) // Should be valid
 	})
 
 	t.Run("Invalid tool call without repair function", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -1348,13 +1363,14 @@ func TestToolCallRepair(t *testing.T) {
 		require.Len(t, result.Steps, 1) // Only one step
 
 		// Check that tool call was marked as invalid
-		toolCalls := result.Steps[0].Response.Content.ToolCalls()
+		toolCalls := result.Steps[0].Content.ToolCalls()
 		require.Len(t, toolCalls, 1)
 		require.True(t, toolCalls[0].Invalid) // Should be invalid
 		require.Contains(t, toolCalls[0].ValidationError.Error(), "missing required parameter: value")
 	})
 
 	t.Run("Invalid tool call with successful repair", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -1402,13 +1418,14 @@ func TestToolCallRepair(t *testing.T) {
 		require.Len(t, result.Steps, 1) // Only one step
 
 		// Check that tool call was repaired and is now valid
-		toolCalls := result.Steps[0].Response.Content.ToolCalls()
+		toolCalls := result.Steps[0].Content.ToolCalls()
 		require.Len(t, toolCalls, 1)
 		require.False(t, toolCalls[0].Invalid)                        // Should be valid after repair
 		require.Equal(t, `{"value": "repaired"}`, toolCalls[0].Input) // Should have repaired input
 	})
 
 	t.Run("Invalid tool call with failed repair", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -1451,13 +1468,14 @@ func TestToolCallRepair(t *testing.T) {
 		require.Len(t, result.Steps, 1) // Only one step
 
 		// Check that tool call was marked as invalid since repair failed
-		toolCalls := result.Steps[0].Response.Content.ToolCalls()
+		toolCalls := result.Steps[0].Content.ToolCalls()
 		require.Len(t, toolCalls, 1)
 		require.True(t, toolCalls[0].Invalid) // Should be invalid
 		require.Contains(t, toolCalls[0].ValidationError.Error(), "missing required parameter: value")
 	})
 
 	t.Run("Nonexistent tool call", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -1488,13 +1506,14 @@ func TestToolCallRepair(t *testing.T) {
 		require.Len(t, result.Steps, 1) // Only one step
 
 		// Check that tool call was marked as invalid due to nonexistent tool
-		toolCalls := result.Steps[0].Response.Content.ToolCalls()
+		toolCalls := result.Steps[0].Content.ToolCalls()
 		require.Len(t, toolCalls, 1)
 		require.True(t, toolCalls[0].Invalid) // Should be invalid
 		require.Contains(t, toolCalls[0].ValidationError.Error(), "tool not found: nonexistent_tool")
 	})
 
 	t.Run("Invalid JSON in tool call", func(t *testing.T) {
+		t.Parallel()
 		model := &mockLanguageModel{
 			generateFunc: func(ctx context.Context, call Call) (*Response, error) {
 				return &Response{
@@ -1532,7 +1551,7 @@ func TestToolCallRepair(t *testing.T) {
 		require.Len(t, result.Steps, 1) // Only one step
 
 		// Check that tool call was marked as invalid due to invalid JSON
-		toolCalls := result.Steps[0].Response.Content.ToolCalls()
+		toolCalls := result.Steps[0].Content.ToolCalls()
 		require.Len(t, toolCalls, 1)
 		require.True(t, toolCalls[0].Invalid) // Should be invalid
 		require.Contains(t, toolCalls[0].ValidationError.Error(), "invalid JSON input")

examples/agent/main.go 🔗

@@ -44,7 +44,6 @@ func main() {
 			if c.GetType() == ai.ContentTypeToolCall {
 				tc, _ := ai.AsContentType[ai.ToolCallContent](c)
 				fmt.Println("ToolCall: ", tc.ToolName)
-
 			}
 		}
 	}

examples/streaming-agent-simple/main.go 🔗

@@ -84,4 +84,3 @@ func main() {
 	fmt.Printf("\n\nFinal result: %s\n", result.Response.Content.Text())
 	fmt.Printf("Steps: %d, Total tokens: %d\n", len(result.Steps), result.TotalUsage.TotalTokens)
 }
-

providers/openai.go 🔗

@@ -634,7 +634,6 @@ func (o openAILanguageModel) Stream(ctx context.Context, call ai.Call) (ai.Strea
 								existingToolCall.hasFinished = true
 								toolCalls[toolCallDelta.Index] = existingToolCall
 							}
-
 						} else {
 							// Does not exist
 							var err error
@@ -721,7 +720,6 @@ func (o openAILanguageModel) Stream(ctx context.Context, call ai.Call) (ai.Strea
 					}
 				}
 			}
-
 		}
 		err := stream.Err()
 		if err == nil || errors.Is(err, io.EOF) {
@@ -766,7 +764,6 @@ func (o openAILanguageModel) Stream(ctx context.Context, call ai.Call) (ai.Strea
 				ProviderMetadata: streamProviderMetadata,
 			})
 			return
-
 		} else {
 			yield(ai.StreamPart{
 				Type:  ai.StreamPartTypeError,

providers/openai_test.go 🔗

@@ -2247,7 +2247,7 @@ func TestDoStream(t *testing.T) {
 		require.True(t, len(parts) >= 4) // text-start, deltas, text-end, finish
 
 		// Find text parts
-		var textStart, textEnd, finish int = -1, -1, -1
+		textStart, textEnd, finish := -1, -1, -1
 		var deltas []string
 
 		for i, part := range parts {

tool_test.go 🔗

@@ -208,4 +208,3 @@ func TestSchemaToParameters(t *testing.T) {
 		t.Errorf("Expected 3 enum values, got %v", enumValues)
 	}
 }
-