Skip to content

Commit b2fbe83

Browse files
committed
fix(web_search): add diagnostic logging for Brave empty results
When the Brave Search API returns HTTP 200 with zero results, log a warning with the response body preview to help diagnose silent failures. This addresses cases where the API response format has changed or a non-standard error response is misinterpreted as a successful empty result, leaving the LLM with a misleading "No results" message. Previously, empty results were silently returned to the LLM as "No results for: <query>", making it impossible to distinguish between genuinely empty results and API format mismatches or silent errors. Closes #3125
1 parent a16a1e1 commit b2fbe83

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

pkg/tools/integration/web.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,19 @@ func (p *BraveSearchProvider) Search(
350350

351351
results := searchResp.Web.Results
352352
if len(results) == 0 {
353+
// Log a warning when the API returned 200 but no results.
354+
// This helps diagnose API format changes or silent errors
355+
// where the response body does not match the expected structure.
356+
bodyPreview := string(body)
357+
if len(bodyPreview) > 300 {
358+
bodyPreview = bodyPreview[:300]
359+
}
360+
logger.WarnCF("web_search", "Brave API returned empty results",
361+
map[string]any{
362+
"query": query,
363+
"status": resp.StatusCode,
364+
"body_preview": bodyPreview,
365+
})
353366
return fmt.Sprintf("No results for: %s", query), nil
354367
}
355368

0 commit comments

Comments
 (0)