The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(mcp): skip image assets when collecting tool result links
oxoxDevc5d7d1201e7f
diff --git a/crates/openhuman-core/src/mcp/ui/links.rs b/crates/openhuman-core/src/mcp/ui/links.rsindex 49904c7d3e..2cfd9b78ff 100644--- a/crates/openhuman-core/src/mcp/ui/links.rs+++ b/crates/openhuman-core/src/mcp/ui/links.rs@@ -14,6 +14,10 @@ use super::types::{UiLink, UiLinkKind};pub const MAX_LINKS: usize = 5;const MAX_URL_LEN: usize = 2048;++const IMAGE_EXTENSIONS: &[&str] = &[+ "jpg", "jpeg", "png", "gif", "webp", "avif", "svg", "bmp", "ico", "heic", "heif", "tif", "tiff",+];const MAX_WALK_DEPTH: usize = 8;const MAX_WALK_STRINGS: usize = 512;@@ -92,6 +96,9 @@ pub fn extract_links(structured: Option<&Value>, text: &str) -> Vec<UiLink> {tracing::trace!("[mcp_ui] dropped a blocked link");continue;};+ if kind == UiLinkKind::External && is_image_url(url) {+ continue;+ }if out.iter().any(|link| link.url == url) {continue;}@@ -104,6 +111,20 @@ pub fn extract_links(structured: Option<&Value>, text: &str) -> Vec<UiLink> {out}+/// Whether an `http(s)` URL points at an image asset rather than a page.+#[must_use]+pub fn is_image_url(url: &str) -> bool {+ let Ok(parsed) = url::Url::parse(url) else {+ return false;+ };+ let path = parsed.path().to_ascii_lowercase();+ if path.contains("/image/upload/") {+ return true;+ }+ path.rsplit_once('.')+ .is_some_and(|(_, ext)| !ext.contains('/') && IMAGE_EXTENSIONS.contains(&ext))+}+fn collect_strings<'a>(value: &'a Value, depth: usize, out: &mut Vec<&'a str>) {if depth > MAX_WALK_DEPTH || out.len() >= MAX_WALK_STRINGS {return;diff --git a/crates/openhuman-core/src/mcp/ui/links_tests.rs b/crates/openhuman-core/src/mcp/ui/links_tests.rsindex 797386d891..6f45078cd9 100644--- a/crates/openhuman-core/src/mcp/ui/links_tests.rs+++ b/crates/openhuman-core/src/mcp/ui/links_tests.rs@@ -80,3 +80,32 @@ fn trims_markdown_punctuation_and_unbalanced_parens() {vec!["https://pay.example.com/x", "https://a.example.com/p_(1)"]);}++#[test]+fn drops_image_assets() {+ let structured = json!({+ "a_image": "https://media-assets.swiggy.com/swiggy/image/upload/fl_lossy,f_auto,q_auto/NI_CATALOG/IMAGES/CIW/2026/6/4/x_1",+ "b_photo": "https://cdn.example.com/products/bar_1.JPG",+ "c_page": "https://www.swiggy.com/instamart/item/123",+ });+ let text = "Logo https://cdn.example.com/logo.svg?v=2 and pay at upi://[email protected]";+ let links = extract_links(Some(&structured), text);+ assert_eq!(+ urls(&links),+ vec![+ "https://www.swiggy.com/instamart/item/123",+ "upi://[email protected]"+ ]+ );+}++#[test]+fn image_url_table() {+ assert!(is_image_url(+ "https://res.cloudinary.com/demo/image/upload/sample"+ ));+ assert!(is_image_url("https://cdn.example.com/a/b.webp"));+ assert!(!is_image_url("https://example.com/pngs/list"));+ assert!(!is_image_url("https://example.com/checkout"));+ assert!(!is_image_url("not a url"));+}