Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/tools/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func (t *WebFetchTool) Execute(ctx context.Context, args map[string]interface{})
resultJSON, _ := json.MarshalIndent(result, "", " ")

return &ToolResult{
ForLLM: fmt.Sprintf("Fetched %d bytes from %s (extractor: %s, truncated: %v)", len(text), urlStr, extractor, truncated),
ForLLM: fmt.Sprintf("Fetched %d bytes from %s (extractor: %s, truncated: %v)\n\n%s", len(text), urlStr, extractor, truncated, text),
ForUser: string(resultJSON),
}
}
Expand Down
25 changes: 20 additions & 5 deletions pkg/tools/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ func TestWebTool_WebFetch_Success(t *testing.T) {
t.Errorf("Expected ForUser to contain 'Test Page', got: %s", result.ForUser)
}

// ForLLM should contain summary
if !strings.Contains(result.ForLLM, "bytes") && !strings.Contains(result.ForLLM, "extractor") {
t.Errorf("Expected ForLLM to contain summary, got: %s", result.ForLLM)
// ForLLM should contain summary metadata
if !strings.Contains(result.ForLLM, "bytes") || !strings.Contains(result.ForLLM, "extractor") {
t.Errorf("Expected ForLLM to contain summary metadata, got: %s", result.ForLLM)
}

// ForLLM should contain the actual fetched page content
if !strings.Contains(result.ForLLM, "Test Page") {
t.Errorf("Expected ForLLM to contain actual page content 'Test Page', got: %s", result.ForLLM)
}
}

Expand Down Expand Up @@ -68,9 +73,14 @@ func TestWebTool_WebFetch_JSON(t *testing.T) {
}

// ForUser should contain formatted JSON
if !strings.Contains(result.ForUser, "key") && !strings.Contains(result.ForUser, "value") {
if !strings.Contains(result.ForUser, "key") || !strings.Contains(result.ForUser, "value") {
t.Errorf("Expected ForUser to contain JSON data, got: %s", result.ForUser)
}

// ForLLM should contain the actual JSON content, not just metadata
if !strings.Contains(result.ForLLM, "key") || !strings.Contains(result.ForLLM, "value") {
t.Errorf("Expected ForLLM to contain actual JSON content, got: %s", result.ForLLM)
}
}

// TestWebTool_WebFetch_InvalidURL verifies error handling for invalid URL
Expand Down Expand Up @@ -224,14 +234,19 @@ func TestWebTool_WebFetch_HTMLExtraction(t *testing.T) {
}

// ForUser should contain extracted text (without script/style tags)
if !strings.Contains(result.ForUser, "Title") && !strings.Contains(result.ForUser, "Content") {
if !strings.Contains(result.ForUser, "Title") || !strings.Contains(result.ForUser, "Content") {
t.Errorf("Expected ForUser to contain extracted text, got: %s", result.ForUser)
}

// Should NOT contain script or style tags
if strings.Contains(result.ForUser, "<script>") || strings.Contains(result.ForUser, "<style>") {
t.Errorf("Expected script/style tags to be removed, got: %s", result.ForUser)
}

// ForLLM should also contain the extracted text content
if !strings.Contains(result.ForLLM, "Title") || !strings.Contains(result.ForLLM, "Content") {
t.Errorf("Expected ForLLM to contain extracted text content, got: %s", result.ForLLM)
}
}

// TestWebFetchTool_extractText verifies text extraction preserves newlines
Expand Down