From b2fbe83565a36355d3a7faa70906640e7bcc2082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=87=91=E5=9F=8E0668000897?= Date: Wed, 17 Jun 2026 15:50:28 +0800 Subject: [PATCH] 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: ", making it impossible to distinguish between genuinely empty results and API format mismatches or silent errors. Closes #3125 --- pkg/tools/integration/web.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/tools/integration/web.go b/pkg/tools/integration/web.go index 4e1bb0fe..fab3f905 100644 --- a/pkg/tools/integration/web.go +++ b/pkg/tools/integration/web.go @@ -350,6 +350,19 @@ func (p *BraveSearchProvider) Search( results := searchResp.Web.Results if len(results) == 0 { + // Log a warning when the API returned 200 but no results. + // This helps diagnose API format changes or silent errors + // where the response body does not match the expected structure. + bodyPreview := string(body) + if len(bodyPreview) > 300 { + bodyPreview = bodyPreview[:300] + } + logger.WarnCF("web_search", "Brave API returned empty results", + map[string]any{ + "query": query, + "status": resp.StatusCode, + "body_preview": bodyPreview, + }) return fmt.Sprintf("No results for: %s", query), nil }