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
refactor(core): move OverlapRanker into discovery module
Steven Enamakel076bb1d839f4
diff --git a/crates/openhuman-cli/src/bin/tool_search_bench.rs b/crates/openhuman-cli/src/bin/tool_search_bench.rsindex 0ebf72958c..472b934659 100644--- a/crates/openhuman-cli/src/bin/tool_search_bench.rs+++ b/crates/openhuman-cli/src/bin/tool_search_bench.rs@@ -271,36 +271,7 @@ fn load_intents(path: &PathBuf) -> Result<Vec<IntentRow>> {Ok(rows)}-/// The token-overlap ranker the Composio sub-agent narrows with, behind the-/// same trait so the loop below treats every ranker alike.-struct OverlapRanker;--#[async_trait::async_trait]-impl ToolRanker for OverlapRanker {- fn kind(&self) -> &'static str {- "overlap"- }-- async fn rank(- &self,- intent: &str,- _context: &RankContext,- candidates: &[RankCandidate],- limit: usize,- ) -> std::result::Result<Vec<RankHit>, tinytools::RankError> {- use tinyagents_harness::tool::select::{rank_tools_by_prompt, SelectableTool};- let selectable: Vec<SelectableTool<'_>> = candidates- .iter()- .map(|c| SelectableTool::new(&c.key, &c.summary))- .collect();- let hits = rank_tools_by_prompt(intent, &selectable, limit);- Ok(hits- .into_iter()- .enumerate()- .map(|(rank, i)| RankHit::new(candidates[i].key.clone(), 1.0 / (rank as f64 + 1.0)))- .collect())- }-}+use openhuman_core::agent::tinyagents::discovery::OverlapRanker;#[cfg(feature = "jev")]fn jev_ranker(retrieval_k: usize) -> Option<(Arc<dyn ToolRanker>, Arc<tinytools_jev::JevRanker>)> {diff --git a/crates/openhuman-core/src/agent/tinyagents/discovery.rs b/crates/openhuman-core/src/agent/tinyagents/discovery.rsindex 9f84c79dc4..92807ddbb7 100644--- a/crates/openhuman-core/src/agent/tinyagents/discovery.rs+++ b/crates/openhuman-core/src/agent/tinyagents/discovery.rs@@ -122,6 +122,52 @@ pub(crate) fn discovery_policy() -> ToolDiscoveryPolicy {policy}+/// The verb-gated token-overlap ranker the Composio sub-agent narrows its+/// toolkit with (`tinyagents_harness::tool::select::rank_tools_by_prompt`),+/// behind the [`ToolRanker`] trait so it can be installed, compared, or+/// benchmarked like any other. Not installed by default — it is the+/// baseline the search was measured against, kept callable on purpose.+#[derive(Debug, Default, Clone, Copy)]+pub struct OverlapRanker;++impl OverlapRanker {+ /// The stable [`ToolRanker::kind`] of this ranker.+ pub const KIND: &'static str = "overlap";+}++#[async_trait::async_trait]+impl ToolRanker for OverlapRanker {+ fn kind(&self) -> &'static str {+ Self::KIND+ }++ async fn rank(+ &self,+ intent: &str,+ _context: &tinytools::RankContext,+ candidates: &[tinytools::RankCandidate],+ limit: usize,+ ) -> Result<Vec<tinytools::RankHit>, tinytools::RankError> {+ use tinyagents_harness::tool::{rank_tools_by_prompt, SelectableTool};+ if intent.trim().is_empty() {+ return Err(tinytools::RankError::InvalidInput {+ reason: "intent is empty".to_owned(),+ });+ }+ let selectable: Vec<SelectableTool<'_>> = candidates+ .iter()+ .map(|c| SelectableTool::new(&c.key, &c.summary))+ .collect();+ Ok(rank_tools_by_prompt(intent, &selectable, limit)+ .into_iter()+ .enumerate()+ .map(|(rank, i)| {+ tinytools::RankHit::new(candidates[i].key.clone(), 1.0 / (rank as f64 + 1.0))+ })+ .collect())+ }+}+#[cfg(test)]#[path = "discovery_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/discovery_tests.rs b/crates/openhuman-core/src/agent/tinyagents/discovery_tests.rsindex 49f600a613..c27c2063eb 100644--- a/crates/openhuman-core/src/agent/tinyagents/discovery_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/discovery_tests.rs@@ -48,3 +48,22 @@ fn settings_select_the_mode_and_clamp_top_k() {clear_tool_ranker();apply_tool_search_config(&ToolSearchConfig::default());}++#[tokio::test]+async fn overlap_ranker_ranks_by_token_overlap_and_names_its_kind() {+ let ranker = OverlapRanker;+ assert_eq!(ranker.kind(), "overlap");+ let candidates = vec![+ tinytools::RankCandidate::new("SLACK_SEND_MESSAGE", "SLACK_SEND_MESSAGE send message to a channel"),+ tinytools::RankCandidate::new("GMAIL_FETCH_EMAILS", "GMAIL_FETCH_EMAILS fetch emails from inbox"),+ ];+ let hits = ranker+ .rank("send a message to the channel", &tinytools::RankContext::empty(), &candidates, 3)+ .await+ .unwrap();+ assert_eq!(hits.first().map(|h| h.key.as_str()), Some("SLACK_SEND_MESSAGE"));+ assert!(ranker+ .rank(" ", &tinytools::RankContext::empty(), &candidates, 3)+ .await+ .is_err());+}