diff --git a/agent/llm/providers/openai/openai.go b/agent/llm/providers/openai/openai.go index 7cb21243..1e7b0e9c 100644 --- a/agent/llm/providers/openai/openai.go +++ b/agent/llm/providers/openai/openai.go @@ -647,7 +647,7 @@ func (p *Provider) streamWithRetry(ctx *context.Context, messages []context.Mess // Log request for debugging if trace != nil { - if requestBodyJSON, marshalErr := jsoniter.Marshal(requestBody); marshalErr == nil { + if requestBodyJSON, marshalErr := jsoniter.Marshal(requestBody); marshalErr == nil { trace.Debug("OpenAI Stream Request", map[string]any{ "url": url, "body": string(requestBodyJSON), @@ -766,12 +766,12 @@ func (p *Provider) streamWithRetry(ctx *context.Context, messages []context.Mess if trace != nil { trace.Warn("OpenAI stream completed but no data was received") - // Log request details for debugging - if requestBodyJSON, err := jsoniter.Marshal(requestBody); err == nil { + // Log request details for debugging + if requestBodyJSON, err := jsoniter.Marshal(requestBody); err == nil { trace.Error("Request body that caused empty response", map[string]any{ "body": string(requestBodyJSON), }) - } + } trace.Error("Request details", map[string]any{ "url": url, "model": accumulator.model, @@ -1057,7 +1057,7 @@ func (p *Provider) postWithRetry(ctx *context.Context, messages []context.Messag } // Log full response data for debugging if trace != nil { - if respJSON, err := jsoniter.Marshal(resp.Data); err == nil { + if respJSON, err := jsoniter.Marshal(resp.Data); err == nil { trace.Error("OpenAI API error response", map[string]any{ "response": string(respJSON), }) diff --git a/openapi/tests/trace/common_test.go b/openapi/tests/trace/common_test.go index 10e41c4e..65508e51 100644 --- a/openapi/tests/trace/common_test.go +++ b/openapi/tests/trace/common_test.go @@ -14,17 +14,17 @@ import ( // testTraceData holds the prepared test trace and related information type testTraceData struct { - TraceID string - Manager types.Manager - RootNodeID string - Node1ID string - Node2ID string - Node3ID string - TokenInfo *testutils.TokenInfo - TestClient *oauthtypes.ClientInfo - ServerURL string - BaseURL string - Ctx context.Context + TraceID string + Manager types.Manager + RootNodeID string + Node1ID string + Node2ID string + Node3ID string + TokenInfo *testutils.TokenInfo + TestClient *oauthtypes.ClientInfo + ServerURL string + BaseURL string + Ctx context.Context } // prepareTestTrace creates a test trace with sample nodes, logs, and spaces @@ -161,4 +161,3 @@ func cleanupTestTrace(t *testing.T, data *testTraceData) { } testutils.Clean() } - diff --git a/openapi/tests/trace/logs_test.go b/openapi/tests/trace/logs_test.go index b4bd90b9..d93006c5 100644 --- a/openapi/tests/trace/logs_test.go +++ b/openapi/tests/trace/logs_test.go @@ -33,7 +33,7 @@ func TestGetLogs(t *testing.T) { // Parse response body, err := io.ReadAll(resp.Body) assert.NoError(t, err) - + var responseData map[string]interface{} err = json.Unmarshal(body, &responseData) assert.NoError(t, err) @@ -46,7 +46,7 @@ func TestGetLogs(t *testing.T) { logs, ok := responseData["logs"].([]interface{}) assert.True(t, ok, "Logs should be an array") assert.NotEmpty(t, logs, "Logs array should not be empty") - + count := int(responseData["count"].(float64)) assert.GreaterOrEqual(t, count, 6, "Should have at least 6 log entries (6 node logs)") diff --git a/openapi/tests/trace/nodes_test.go b/openapi/tests/trace/nodes_test.go index 877fc886..144a7c38 100644 --- a/openapi/tests/trace/nodes_test.go +++ b/openapi/tests/trace/nodes_test.go @@ -33,7 +33,7 @@ func TestGetNodes(t *testing.T) { // Parse response body, err := io.ReadAll(resp.Body) assert.NoError(t, err) - + var responseData map[string]interface{} err = json.Unmarshal(body, &responseData) assert.NoError(t, err) @@ -46,7 +46,7 @@ func TestGetNodes(t *testing.T) { nodes, ok := responseData["nodes"].([]interface{}) assert.True(t, ok, "Nodes should be an array") assert.NotEmpty(t, nodes, "Nodes array should not be empty") - + count := int(responseData["count"].(float64)) assert.Equal(t, 3, count, "Should have 3 nodes (3 child nodes created)") assert.Equal(t, count, len(nodes), "Count should match array length") @@ -60,7 +60,7 @@ func TestGetNodes(t *testing.T) { assert.NotNil(t, node["label"], "Node should have label") assert.NotNil(t, node["status"], "Node should have status") assert.NotNil(t, node["created_at"], "Node should have created_at") - + // Check if metadata is present (should be for all our test nodes) if node["metadata"] != nil { metadata, ok := node["metadata"].(map[string]interface{}) @@ -71,7 +71,7 @@ func TestGetNodes(t *testing.T) { } } } - + assert.Equal(t, 3, metadataFound, "All 3 nodes should have metadata with node_order") t.Logf("Retrieved %d nodes for trace %s (all with metadata)", count, data.TraceID) @@ -109,13 +109,13 @@ func TestGetNodeByID(t *testing.T) { assert.Equal(t, "First Node", responseData["label"], "Node label should match") assert.Equal(t, "icon1", responseData["icon"], "Node icon should match") assert.Equal(t, "First test node", responseData["description"], "Node description should match") - + // Verify metadata is present and correct assert.NotNil(t, responseData["metadata"], "Metadata should be present") metadata, ok := responseData["metadata"].(map[string]interface{}) assert.True(t, ok, "Metadata should be a map") assert.Equal(t, float64(1), metadata["node_order"], "Metadata node_order should be 1") - + // Verify input and output are present assert.NotNil(t, responseData["input"], "Input should be present") assert.NotNil(t, responseData["output"], "Output should be present") diff --git a/openapi/tests/trace/spaces_test.go b/openapi/tests/trace/spaces_test.go index b2e1258a..12294f37 100644 --- a/openapi/tests/trace/spaces_test.go +++ b/openapi/tests/trace/spaces_test.go @@ -165,4 +165,3 @@ func TestGetSpaceByIDNotFound(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, result["error"]) } - diff --git a/openapi/trace/nodes.go b/openapi/trace/nodes.go index ab7fee1f..2b5b1d43 100644 --- a/openapi/trace/nodes.go +++ b/openapi/trace/nodes.go @@ -152,4 +152,3 @@ func GetNode(c *gin.Context) { response.RespondWithSuccess(c, response.StatusOK, nodeData) } - diff --git a/openapi/trace/spaces.go b/openapi/trace/spaces.go index 44bd336f..253a1646 100644 --- a/openapi/trace/spaces.go +++ b/openapi/trace/spaces.go @@ -136,4 +136,3 @@ func GetSpace(c *gin.Context) { response.RespondWithSuccess(c, response.StatusOK, responseData) } -