Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(openhuman-core): handle empty search results from Brave API

Steven Enamakel33a9c9c07103
diff --git a/crates/openhuman-core/src/search/tools/brave.rs b/crates/openhuman-core/src/search/tools/brave.rs
index 9cb5b9ed9b..0fb7876eca 100644
--- a/crates/openhuman-core/src/search/tools/brave.rs
+++ b/crates/openhuman-core/src/search/tools/brave.rs
@@ -233,6 +233,28 @@ impl Tool for BraveWebSearchTool {
if options.prefer_markdown {
out.markdown_formatted = Some(render_web_markdown(&results, &query, count));
}
+ // Host-only structured payload for the chat UI's tool-call
+ // presentation — never rendered to the model, so `render_web_plain`'s
+ // text above (and the cache key that depends on it) is unaffected.
+ let structured_results: Vec<crate::search::tools::WebSearchResultRef<'_>> = results
+ .iter()
+ .map(|r| crate::search::tools::WebSearchResultRef {
+ title: if r.title.trim().is_empty() {
+ "Untitled"
+ } else {
+ r.title.trim()
+ },
+ url: r.url.as_str(),
+ published: r.age.as_deref(),
+ excerpt: Some(r.description.as_str()).filter(|d| !d.trim().is_empty()),
+ })
+ .collect();
+ out.metadata = Some(crate::search::tools::web_search_metadata(
+ &query,
+ "Brave",
+ &structured_results,
+ count,
+ ));
Ok(out)
}
}