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(skills): page skill_registry_search results
M3gA-Mindd6fd3ed0b1fc
diff --git a/crates/openhuman-core/src/skills/catalog/tools.rs b/crates/openhuman-core/src/skills/catalog/tools.rsindex 35116fd3c4..3ce62a2f4f 100644--- a/crates/openhuman-core/src/skills/catalog/tools.rs+++ b/crates/openhuman-core/src/skills/catalog/tools.rs@@ -66,6 +66,14 @@ impl Tool for SkillRegistryBrowseTool {pub struct SkillRegistrySearchTool;+/// Matches returned per `skill_registry_search` call when the caller does not+/// say: enough candidates to compare and pick from in one read. A broad query+/// over the ~100k-entry catalog matches hundreds, and returning them all makes+/// every search a payload the harness has to summarize first (#6286).+const SEARCH_DEFAULT_LIMIT: usize = 20;+/// Largest page a caller may ask for.+const SEARCH_MAX_LIMIT: usize = 100;+#[async_trait]impl Tool for SkillRegistrySearchTool {fn name(&self) -> &str {@@ -74,7 +82,9 @@ impl Tool for SkillRegistrySearchTool {fn description(&self) -> &str {"Search available skills by keyword. Matches against name, description, \- tags, category, and author. Optionally filter by source or category."+ tags, category, and author. Optionally filter by source or category. \+ Returns one page of matches (`limit`, default 20) with the `total` \+ match count; pass `next_offset` as `offset` to read the next page."}fn parameters_schema(&self) -> serde_json::Value {@@ -92,6 +102,19 @@ impl Tool for SkillRegistrySearchTool {"category": {"type": "string","description": "Filter by category."+ },+ "limit": {+ "type": "integer",+ "minimum": 1,+ "maximum": SEARCH_MAX_LIMIT,+ "default": SEARCH_DEFAULT_LIMIT,+ "description": "Maximum number of matches to return."+ },+ "offset": {+ "type": "integer",+ "minimum": 0,+ "default": 0,+ "description": "Number of matches to skip. Pass `next_offset` from the previous page."}},"required": ["query"]@@ -102,19 +125,46 @@ impl Tool for SkillRegistrySearchTool {let query = args.get("query").and_then(|v| v.as_str()).unwrap_or("");let source_filter = args.get("source").and_then(|v| v.as_str());let category_filter = args.get("category").and_then(|v| v.as_str());+ let limit = args+ .get("limit")+ .and_then(|v| v.as_u64())+ .map_or(SEARCH_DEFAULT_LIMIT, |n| {+ usize::try_from(n).map_or(SEARCH_MAX_LIMIT, |n| n.clamp(1, SEARCH_MAX_LIMIT))+ });+ let offset = args+ .get("offset")+ .and_then(|v| v.as_u64())+ .map_or(0, |n| usize::try_from(n).unwrap_or(usize::MAX));tracing::debug!(query = %query,source = ?source_filter,category = ?category_filter,+ limit,+ offset,"[tool][skill_registry] search");match ops::search_catalog(query, source_filter, category_filter).await {- Ok(entries) => Ok(ToolResult::success(serde_json::to_string(&json!({- "count": entries.len(),- "entries": entries,- }))?)),+ Ok(entries) => {+ let total = entries.len();+ let page: Vec<_> = entries.into_iter().skip(offset).take(limit).collect();+ let end = offset.saturating_add(page.len());+ let next_offset = (end < total).then_some(end);+ tracing::debug!(+ total,+ returned = page.len(),+ next_offset = ?next_offset,+ "[tool][skill_registry] search page"+ );+ Ok(ToolResult::success(serde_json::to_string(&json!({+ "total": total,+ "offset": offset,+ "count": page.len(),+ "next_offset": next_offset,+ "entries": page,+ }))?))+ }Err(e) => Ok(ToolResult::error(format!("Failed to search skill catalog: {e}"))),diff --git a/crates/openhuman-core/src/skills/catalog/tools_tests.rs b/crates/openhuman-core/src/skills/catalog/tools_tests.rsindex af7b4b22cb..d5d3800c04 100644--- a/crates/openhuman-core/src/skills/catalog/tools_tests.rs+++ b/crates/openhuman-core/src/skills/catalog/tools_tests.rs@@ -19,3 +19,55 @@ fn read_only_skill_tools_are_not_gated() {assert!(!SkillRegistrySearchTool.external_effect());assert!(!SkillRegistrySourcesTool.external_effect());}++async fn search_page(args: serde_json::Value) -> serde_json::Value {+ let result = SkillRegistrySearchTool+ .execute(args)+ .await+ .expect("execute");+ serde_json::from_str(&result.output()).expect("search result is json")+}++#[tokio::test]+async fn search_tool_returns_a_bounded_page_and_where_the_next_one_starts() {+ // #6286: a broad query used to return every match in one result.+ let _env = crate::skills::catalog::TEST_ENV_LOCK+ .lock()+ .unwrap_or_else(|e| e.into_inner());+ let tmp = tempfile::tempdir().unwrap();+ std::env::set_var("OPENHUMAN_SKILL_REGISTRY_CACHE_DIR", tmp.path());+ let catalog: Vec<_> = (0..45)+ .map(|i| {+ ops::parse_hermes_entry(&json!({+ "name": format!("review-{i:02}"),+ "description": "x",+ "source": "built-in"+ }))+ .expect("entry")+ })+ .collect();+ crate::skills::catalog::store::save_catalog_cache(&catalog);++ let first = search_page(json!({ "query": "review" })).await;+ assert_eq!(first["total"], 45);+ assert_eq!(+ first["count"], SEARCH_DEFAULT_LIMIT,+ "default page is bounded"+ );+ assert_eq!(+ first["entries"].as_array().map(Vec::len),+ Some(SEARCH_DEFAULT_LIMIT)+ );+ assert_eq!(first["next_offset"], SEARCH_DEFAULT_LIMIT);++ let last = search_page(json!({ "query": "review", "offset": 40, "limit": 10 })).await;+ assert_eq!(last["count"], 5);+ assert_eq!(last["entries"][0]["id"], "review-40");+ assert!(last["next_offset"].is_null(), "no page after the last one");++ let clamped = search_page(json!({ "query": "review", "limit": 0 })).await;+ assert_eq!(clamped["count"], 1, "limit is at least 1");++ crate::skills::catalog::store::clear_cache();+ std::env::remove_var("OPENHUMAN_SKILL_REGISTRY_CACHE_DIR");+}