Skip to content

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

chore: reformat long lines and fix import ordering across multiple crates

Steven Enamakel4ccd374a0478
diff --git a/crates/openhuman-cli/src/bin/tool_search_bench.rs b/crates/openhuman-cli/src/bin/tool_search_bench.rs
index 5c38894d86..c507485451 100644
--- a/crates/openhuman-cli/src/bin/tool_search_bench.rs
+++ b/crates/openhuman-cli/src/bin/tool_search_bench.rs
@@ -81,7 +81,11 @@ impl CatalogueEntry {
summary.push_str(&self.name.replace('_', " "));
summary.push(' ');
summary.push_str(&self.description);
- if let Some(props) = self.parameters.get("properties").and_then(|v| v.as_object()) {
+ if let Some(props) = self
+ .parameters
+ .get("properties")
+ .and_then(|v| v.as_object())
+ {
for key in props.keys() {
summary.push(' ');
summary.push_str(key);
@@ -360,7 +364,9 @@ fn embedding_retriever() -> Arc<dyn ToolRanker> {
eprintln!("embedding: {} / {}", provider.name(), provider.model_id());
Arc::new(
EmbeddingToolRanker::new(provider).with_disk_cache(
- repo_root().join("target").join("tool_search_bench_embeddings.json"),
+ repo_root()
+ .join("target")
+ .join("tool_search_bench_embeddings.json"),
),
)
}
@@ -446,7 +452,11 @@ async fn main() -> Result<()> {
format!(
"jev({}{})",
if args.family { "family" } else { "retrieve" },
- if args.embedding { "+embedding" } else { "+bm25" }
+ if args.embedding {
+ "+embedding"
+ } else {
+ "+bm25"
+ }
)
} else {
kind.clone()
@@ -479,10 +489,12 @@ async fn main() -> Result<()> {
continue;
}
report.labelled += 1;
- let source = if catalogue
- .iter()
- .any(|e| e.name == row.expected && e.family.as_deref().is_some_and(|f| FIXTURE_TOOLKITS.contains(&f)))
- {
+ let source = if catalogue.iter().any(|e| {
+ e.name == row.expected
+ && e.family
+ .as_deref()
+ .is_some_and(|f| FIXTURE_TOOLKITS.contains(&f))
+ }) {
"composio"
} else {
"core"
@@ -520,7 +532,12 @@ async fn main() -> Result<()> {
ranker.clone()
};
retriever
- .rank(&row.intent, &RankContext::empty(), &candidates, args.retrieval_k)
+ .rank(
+ &row.intent,
+ &RankContext::empty(),
+ &candidates,
+ args.retrieval_k,
+ )
.await
.map(|hits| hits.into_iter().map(|h| h.key).collect())
.unwrap_or_default()
@@ -598,20 +615,48 @@ async fn main() -> Result<()> {
r.errors,
r.percentile(0.5),
r.percentile(0.95),
- if r.input_tokens == 0 { "-".to_string() } else { r.input_tokens.to_string() },
- if r.usd == 0.0 { "-".to_string() } else { format!("${:.5}", r.usd) },
+ if r.input_tokens == 0 {
+ "-".to_string()
+ } else {
+ r.input_tokens.to_string()
+ },
+ if r.usd == 0.0 {
+ "-".to_string()
+ } else {
+ format!("${:.5}", r.usd)
+ },
);
}
- println!("\n| ranker | source | labelled | top-1 | top-3 | recall@{} |", args.retrieval_k);
+ println!(
+ "\n| ranker | source | labelled | top-1 | top-3 | recall@{} |",
+ args.retrieval_k
+ );
println!("|---|---|---|---|---|---|");
for r in &reports {
for (source, (n, t1, t3, rk)) in &r.by_source {
- let pct = |x: usize| if *n == 0 { "n/a".to_string() } else { format!("{:.1}%", 100.0 * x as f64 / *n as f64) };
- println!("| {} | {} | {} | {} | {} | {} |", r.ranker, source, n, pct(*t1), pct(*t3), pct(*rk));
+ let pct = |x: usize| {
+ if *n == 0 {
+ "n/a".to_string()
+ } else {
+ format!("{:.1}%", 100.0 * x as f64 / *n as f64)
+ }
+ };
+ println!(
+ "| {} | {} | {} | {} | {} | {} |",
+ r.ranker,
+ source,
+ n,
+ pct(*t1),
+ pct(*t3),
+ pct(*rk)
+ );
}
}
for r in &reports {
- println!("\n### {} — top-1 family confusion (expected → got)", r.ranker);
+ println!(
+ "\n### {} — top-1 family confusion (expected → got)",
+ r.ranker
+ );
for (expected, gots) in &r.confusion {
let line: Vec<String> = gots.iter().map(|(g, n)| format!("{g}:{n}")).collect();
println!("- {expected}: {}", line.join(", "));
diff --git a/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs b/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs
index 78041eb55c..dd22898f59 100644
--- a/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/harness_tool_call_parsing_edge_case_tests.rs
@@ -12,7 +12,10 @@ fn parse_tool_calls_doubled_xml_tags_are_one_call() {
assert_eq!(calls.len(), 1, "{calls:?}");
assert_eq!(calls[0].name, "echo");
assert_eq!(calls[0].arguments["msg"], "hi");
- assert!(!text.contains("tool_call"), "no tag may survive into the text: {text:?}");
+ assert!(
+ !text.contains("tool_call"),
+ "no tag may survive into the text: {text:?}"
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
index 1a139169fe..03425a03a2 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
@@ -193,8 +193,7 @@ fn named_belt_opts_into_discovery_by_naming_tool_search() {
/// down: no deferred set, and a deferred tool it did not name stays hidden.
#[test]
fn named_belt_without_tool_search_reaches_no_deferred_tool() {
- let visible: std::collections::HashSet<String> =
- std::iter::once("plain".to_string()).collect();
+ let visible: std::collections::HashSet<String> = std::iter::once("plain".to_string()).collect();
let agent = build_with(direct_and_deferred(), visible);
assert!(agent.deferred_tool_names_for_test().is_empty());
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
index 59531004a3..74c7f0071a 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
@@ -129,7 +129,9 @@ impl OpenHumanSessionHost {
}
#[cfg(test)]
- pub(crate) fn tool_policy_session_for_test(&self) -> &crate::tools::agent_policy::ToolPolicySession {
+ pub(crate) fn tool_policy_session_for_test(
+ &self,
+ ) -> &crate::tools::agent_policy::ToolPolicySession {
&self.tool_policy_session
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/discovery/discovery_tests.rs b/crates/openhuman-core/src/agent/tinyagents/discovery/discovery_tests.rs
index b74cfc55a8..406a2084f5 100644
--- a/crates/openhuman-core/src/agent/tinyagents/discovery/discovery_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/discovery/discovery_tests.rs
@@ -54,14 +54,28 @@ 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"),
+ 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)
+ .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_eq!(
+ hits.first().map(|h| h.key.as_str()),
+ Some("SLACK_SEND_MESSAGE")
+ );
assert!(ranker
.rank(" ", &tinytools::RankContext::empty(), &candidates, 3)
.await
diff --git a/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker.rs b/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker.rs
index 5ba8c1f4cf..659493fe8a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker.rs
@@ -130,13 +130,13 @@ impl EmbeddingToolRanker {
);
for batch in missing.chunks(EMBED_BATCH) {
let texts: Vec<&str> = batch.iter().map(|(_, t)| t.as_str()).collect();
- let vectors = self
- .provider
- .embed(&texts)
- .await
- .map_err(|error| RankError::Backend {
- reason: format!("embedding failed: {error:#}"),
- })?;
+ let vectors =
+ self.provider
+ .embed(&texts)
+ .await
+ .map_err(|error| RankError::Backend {
+ reason: format!("embedding failed: {error:#}"),
+ })?;
if vectors.len() != batch.len() {
return Err(RankError::Backend {
reason: format!(
@@ -161,11 +161,7 @@ impl EmbeddingToolRanker {
};
let disk = DiskCache {
signature: self.provider.signature(),
- entries: self
- .cache
- .read()
- .unwrap_or_else(|p| p.into_inner())
- .clone(),
+ entries: self.cache.read().unwrap_or_else(|p| p.into_inner()).clone(),
};
let write = || -> std::io::Result<()> {
if let Some(parent) = path.parent() {
diff --git a/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker_tests.rs b/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker_tests.rs
index d0ab881fdd..d31bbb2bb0 100644
--- a/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/discovery/embedding_ranker_tests.rs
@@ -43,7 +43,8 @@ impl EmbeddingProvider for BagEmbedder {
fn candidates() -> Vec<RankCandidate> {
vec![
- RankCandidate::new("SLACK_SEND_MESSAGE", "send a message to a channel").with_family("slack"),
+ RankCandidate::new("SLACK_SEND_MESSAGE", "send a message to a channel")
+ .with_family("slack"),
RankCandidate::new("GMAIL_SEND_EMAIL", "send an email").with_family("gmail"),
RankCandidate::new("file_read", "read a file"),
]
@@ -131,7 +132,11 @@ async fn a_new_or_changed_tool_is_embedded_incrementally() {
.rank("ping", &RankContext::empty(), &candidates(), 1)
.await
.unwrap();
- assert_eq!(embedder.calls.load(Ordering::SeqCst), 2, "catalogue + intent");
+ assert_eq!(
+ embedder.calls.load(Ordering::SeqCst),
+ 2,
+ "catalogue + intent"
+ );
let mut grown = candidates();
grown.push(RankCandidate::new("NOTION_CREATE_PAGE", "create a page").with_family("notion"));
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
index 609543754f..a5ab3817c8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
@@ -165,9 +165,7 @@ impl OpenHumanHostBundleFactory {
// twice and interleaved the copies in the interim bubble. The sink
// stays registered as the host capability with an unconsumed channel;
// nothing OpenHuman renders depends on it.
- let progress = Arc::new(OpenHumanProgressSink::new(
- tokio::sync::mpsc::channel(1).0,
- ));
+ let progress = Arc::new(OpenHumanProgressSink::new(tokio::sync::mpsc::channel(1).0));
let learning = Arc::new(OpenHumanLearningSink::new(inputs.post_turn_hooks));
let tool_outcomes = Arc::new(OpenHumanToolOutcomeClassifier::new());
let experience = Arc::new(OpenHumanExperienceStore::new(inputs.memory));
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs
index b1fd769d97..504d9df46e 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs
@@ -229,8 +229,12 @@ async fn prompt_cache_segments_are_stable_across_a_threads_turns() {
TaMessage::user("and again, later"),
])
.with_tools(tools);
- mw.before_model(&mut ctx(), &(), &mut turn_one).await.unwrap();
- mw.before_model(&mut ctx(), &(), &mut turn_two).await.unwrap();
+ mw.before_model(&mut ctx(), &(), &mut turn_one)
+ .await
+ .unwrap();
+ mw.before_model(&mut ctx(), &(), &mut turn_two)
+ .await
+ .unwrap();
let ids = |r: &ModelRequest| {
r.cache_segments
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs
index f123217e06..6669d9c202 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner_tests.rs
@@ -194,5 +194,8 @@ async fn a_streamed_delta_reaches_the_progress_channel_exactly_once() {
"every model delta is forwarded once, by one producer"
);
assert!(started <= 1, "TurnStarted was emitted {started} times");
- assert!(completed <= 1, "TurnCompleted was emitted {completed} times");
+ assert!(
+ completed <= 1,
+ "TurnCompleted was emitted {completed} times"
+ );
}
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
index 01585d3f00..ec8016b638 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
@@ -1,8 +1,8 @@
use super::*;
use crate::inference::provider::factory::cloud_slug::{
- openrouter_default_provider_options, try_create_cloud_slug_chat_model_from_string_with_native_tools,
- OPENROUTER_PROVIDER_SORT,
+ openrouter_default_provider_options,
+ try_create_cloud_slug_chat_model_from_string_with_native_tools, OPENROUTER_PROVIDER_SORT,
};
#[test]
fn enforce_local_only_inference_errors_on_external_when_local_only() {
@@ -768,7 +768,10 @@ fn direct_openrouter_endpoints_get_price_sorted_routing_and_nothing_else() {
);
let provider = &options["provider"];
for forbidden in ["order", "allow_fallbacks", "max_price", "only", "ignore"] {
- assert!(provider.get(forbidden).is_none(), "must not set provider.{forbidden}");
+ assert!(
+ provider.get(forbidden).is_none(),
+ "must not set provider.{forbidden}"
+ );
}
// Host matching is what keys it, with or without a path or trailing slash.
assert!(openrouter_default_provider_options("https://openrouter.ai/api/v1/").is_some());
diff --git a/crates/openhuman-core/src/integrations/composio/action_tool.rs b/crates/openhuman-core/src/integrations/composio/action_tool.rs
index 797a652e0c..2a8cac0485 100644
--- a/crates/openhuman-core/src/integrations/composio/action_tool.rs
+++ b/crates/openhuman-core/src/integrations/composio/action_tool.rs
@@ -284,19 +284,19 @@ impl Tool for ComposioActionTool {
// re-resolving process-global `OPENHUMAN_WORKSPACE` (the tool is scoped to
// the user/workspace it was created for).
let live_config = match self.live_config().await {
- Ok(c) => c,
- Err(e) => {
- tracing::warn!(
- tool = %self.action_name,
- error = %e,
- "[composio] per-action execute: load_config failed"
- );
- return Ok(ToolResult::error(format!(
- "{}: failed to load live config: {e}",
- self.action_name
- )));
- }
- };
+ Ok(c) => c,
+ Err(e) => {
+ tracing::warn!(
+ tool = %self.action_name,
+ error = %e,
+ "[composio] per-action execute: load_config failed"
+ );
+ return Ok(ToolResult::error(format!(
+ "{}: failed to load live config: {e}",
+ self.action_name
+ )));
+ }
+ };
// Contract gate (#4853): the per-action tool is built from the thin
// spawn-time `list_tools` schema (often `{"type":"object"}` with no
diff --git a/crates/openhuman-tinyhumans/src/jev/evaluator_tests.rs b/crates/openhuman-tinyhumans/src/jev/evaluator_tests.rs
index dded49826f..a8d159a8b9 100644
--- a/crates/openhuman-tinyhumans/src/jev/evaluator_tests.rs
+++ b/crates/openhuman-tinyhumans/src/jev/evaluator_tests.rs
@@ -31,7 +31,11 @@ fn builds_one_choice_and_one_noul_from_the_request() {
match wire.questions.get("tool") {
Some(Question::Choice(choice)) => {
assert_eq!(choice.criteria.len(), 2);
- assert!(choice.instructions.as_str().unwrap().starts_with("Which tool"));
+ assert!(choice
+ .instructions
+ .as_str()
+ .unwrap()
+ .starts_with("Which tool"));
}
other => panic!("expected a choice, got {other:?}"),
}
diff --git a/crates/openhuman-tinyhumans/src/jev/ranker.rs b/crates/openhuman-tinyhumans/src/jev/ranker.rs
index 4c020c5913..176b2260ec 100644
--- a/crates/openhuman-tinyhumans/src/jev/ranker.rs
+++ b/crates/openhuman-tinyhumans/src/jev/ranker.rs
@@ -13,8 +13,8 @@ use openhuman_core::agent::tinyagents::discovery::EmbeddingToolRanker;
use openhuman_core::api::config::effective_backend_api_url;
use openhuman_core::config::Config;
use openhuman_core::security::credentials::session_support::resolve_backend_credential;
-use tinytools::{RankCandidate, RankContext, RankError, RankHit, ToolRanker};
use tinyjevclient::{Client, ClientConfig};
+use tinytools::{RankCandidate, RankContext, RankError, RankHit, ToolRanker};
use tinytools_jev::{JevRanker, JevRankerConfig, JevStrategy};
use super::evaluator::TinyJevEvaluator;
@@ -22,9 +22,8 @@ use super::evaluator::TinyJevEvaluator;
/// How the ranker reads the config a search runs under. The default is the
/// core's own read path (the embedder's config when one is bound, else the
/// process-global load); a test hands in a fixed one.
-pub type ConfigLoader = Arc<
- dyn Fn() -> Pin<Box<dyn Future<Output = Result<Config, String>> + Send>> + Send + Sync,
->;
+pub type ConfigLoader =
+ Arc<dyn Fn() -> Pin<Box<dyn Future<Output = Result<Config, String>> + Send>> + Send + Sync>;
/// A [`JevRanker`] bound to whichever credential and backend the process has
/// at search time.
@@ -126,7 +125,10 @@ impl TinyHumansJevRanker {
.cached
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner());
- if let Some(entry) = cached.as_ref().filter(|entry| entry.fingerprint == fingerprint) {
+ if let Some(entry) = cached
+ .as_ref()
+ .filter(|entry| entry.fingerprint == fingerprint)
+ {
return Ok(entry.ranker.clone());
}
let mut client_config = ClientConfig::tinyhumans_openrouter(credential.into_secret());
@@ -172,9 +174,8 @@ impl TinyHumansJevRanker {
/// and a Jev decision over a lexical shortlist would only add a network
/// round trip to the same recall.
fn retriever_for(config: &Config) -> Result<Arc<dyn ToolRanker>, RankError> {
- let provider = openhuman_core::inference::embedding_host::default_embedding_provider_with_config(
- config,
- );
+ let provider =
+ openhuman_core::inference::embedding_host::default_embedding_provider_with_config(config);
if !EmbeddingToolRanker::provider_is_usable(provider.as_ref()) {
log::info!(
"[tool-search] embedding provider `{}` cannot embed; jev search disabled, bm25 answers",
diff --git a/crates/openhuman-tinyhumans/src/lib.rs b/crates/openhuman-tinyhumans/src/lib.rs
index 231a93cdc5..410d8019b4 100644
--- a/crates/openhuman-tinyhumans/src/lib.rs
+++ b/crates/openhuman-tinyhumans/src/lib.rs
@@ -37,9 +37,9 @@
pub use openhuman_embed as embed;
pub mod hosted;
+mod install;
#[cfg(feature = "jev")]
pub mod jev;
-mod install;
pub mod jwt;
mod runtime;
pub mod session;