feat(web-search): include thumbnail URLs in search results (#1313)

Brave's API returns thumbnail objects on many web results, but the
WASM tool was silently dropping them during deserialization. This adds
the thumbnail.src field to the output so downstream consumers (chat
UIs, agents) can render product images and rich previews.

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Co-authored-by: Illia Polosukhin <[email protected]>
This commit is contained in:
jack dempsey
2026-03-20 22:16:13 -07:00
committed by GitHub
co-authored by Claude Opus 4.6 Illia Polosukhin
parent 212d661e20
commit 9964d5dab8
+13 -4
View File
@@ -42,10 +42,10 @@ impl exports::near::agent::tool::Guest for WebSearchTool {
}
fn description() -> String {
"Search the web using Brave Search. Returns titles, URLs, descriptions, and \
publication dates for matching web pages. Supports filtering by country, \
language, and freshness. Authentication is handled via the 'brave_api_key' \
secret injected by the host."
"Search the web using Brave Search. Returns titles, URLs, descriptions, \
publication dates, and thumbnail images for matching web pages. Supports \
filtering by country, language, and freshness. Authentication is handled \
via the 'brave_api_key' secret injected by the host."
.to_string()
}
}
@@ -76,6 +76,12 @@ struct BraveSearchResult {
url: Option<String>,
description: Option<String>,
age: Option<String>,
thumbnail: Option<BraveThumbnail>,
}
#[derive(Debug, Deserialize)]
struct BraveThumbnail {
src: Option<String>,
}
fn execute_inner(params: &str) -> Result<String, String> {
@@ -198,6 +204,9 @@ fn execute_inner(params: &str) -> Result<String, String> {
if let Some(age) = r.age {
entry["published"] = serde_json::json!(age);
}
if let Some(thumb) = r.thumbnail.and_then(|t| t.src) {
entry["thumbnail"] = serde_json::json!(thumb);
}
// Extract hostname for site_name.
if let Some(host) = extract_hostname(&url) {
entry["site_name"] = serde_json::json!(host);