Skip to content

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

style: apply rustfmt formatting to inference readiness code

Steven Enamakel0ce88bd3feb3
diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness.rs b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
index 851f103ce5..0a958949fa 100644
--- a/crates/openhuman-core/src/flows/ops/inference_readiness.rs
+++ b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
@@ -23,13 +23,14 @@ pub(super) fn agent_node_role(config: &Config, node: &tinyflows::model::Node) ->
} else {
custom.as_ref().and_then(|entry| entry.model.as_deref())
};
- let override_model = crate::flows::tinyflows::caps::resolve_node_model(
- &node.config,
- entry_model,
- )
- .map(|model| crate::flows::tinyflows::caps::harness_model_default_override(&model));
+ let override_model =
+ crate::flows::tinyflows::caps::resolve_node_model(&node.config, entry_model).map(
+ |model| crate::flows::tinyflows::caps::harness_model_default_override(&model),
+ );
return crate::agent::session_host::provider_role_for_definition(
- override_model.as_deref().or(config.default_model.as_deref()),
+ override_model
+ .as_deref()
+ .or(config.default_model.as_deref()),
definition.as_ref(),
);
}
@@ -46,7 +47,9 @@ pub(super) fn agent_node_role(config: &Config, node: &tinyflows::model::Node) ->
"summarization"
}
-fn format_evaluation(evaluation: crate::inference::readiness::ReadinessEvaluation) -> Option<String> {
+fn format_evaluation(
+ evaluation: crate::inference::readiness::ReadinessEvaluation,
+) -> Option<String> {
if evaluation.status == "ready" {
return None;
}
@@ -60,7 +63,10 @@ fn format_evaluation(evaluation: crate::inference::readiness::ReadinessEvaluatio
failure.message
)
} else {
- format!("This flow's agent step needs a working AI provider: {}", failure.message)
+ format!(
+ "This flow's agent step needs a working AI provider: {}",
+ failure.message
+ )
});
}
}
@@ -75,7 +81,10 @@ fn format_evaluation(evaluation: crate::inference::readiness::ReadinessEvaluatio
.collect::<Vec<_>>()
.join(", ");
if evaluation.status == "provider_not_configured"
- && failure.message.to_ascii_lowercase().contains("api key not configured")
+ && failure
+ .message
+ .to_ascii_lowercase()
+ .contains("api key not configured")
{
format!(
"Node(s) {nodes} (role `{}`): the provider returned: '{}'. Configure \
@@ -83,7 +92,10 @@ fn format_evaluation(evaluation: crate::inference::readiness::ReadinessEvaluatio
failure.role, failure.message
)
} else {
- format!("Node(s) {nodes} (role `{}`): {}", failure.role, failure.message)
+ format!(
+ "Node(s) {nodes} (role `{}`): {}",
+ failure.role, failure.message
+ )
}
})
.collect::<Vec<_>>()
@@ -122,7 +134,10 @@ pub(crate) async fn validate_inference_readiness(
return Vec::new();
};
if evaluation.failures.len() == 1 && evaluation.failures[0].node_ids.len() == 1 {
- vec![format!("Node '{}': {message}", evaluation.failures[0].node_ids[0])]
+ vec![format!(
+ "Node '{}': {message}",
+ evaluation.failures[0].node_ids[0]
+ )]
} else {
vec![message]
}
diff --git a/crates/openhuman-core/src/inference/readiness.rs b/crates/openhuman-core/src/inference/readiness.rs
index aaacac1a88..8d9907aa95 100644
--- a/crates/openhuman-core/src/inference/readiness.rs
+++ b/crates/openhuman-core/src/inference/readiness.rs
@@ -32,8 +32,7 @@ pub struct ReadinessEvaluation {
pub failures: Vec<ReadinessFailure>,
}
-static PROBE_CACHE: LazyLock<Mutex<Cache>> =
- LazyLock::new(|| Mutex::new(HashMap::new()));
+static PROBE_CACHE: LazyLock<Mutex<Cache>> = LazyLock::new(|| Mutex::new(HashMap::new()));
fn invalidate_cache_if_signed_out() {
if crate::platform::llm_gate::is_signed_out() {
@@ -45,11 +44,7 @@ fn invalidate_cache_if_signed_out() {
}
/// Probe one role, caching both definitive success and failure for one minute.
-pub async fn cached_probe(
- ctx: &DispatchCtx,
- role: &str,
- config: &Config,
-) -> Result<(), String> {
+pub async fn cached_probe(ctx: &DispatchCtx, role: &str, config: &Config) -> Result<(), String> {
invalidate_cache_if_signed_out();
let key = (role.to_string(), config.config_path.clone());
if let Some((checked_at, result)) = PROBE_CACHE
@@ -134,7 +129,9 @@ pub async fn evaluate(
status: "signed_out",
failures: vec![ReadinessFailure {
role: nodes[0].1,
- message: format!("Inference unavailable: {error} Sign in to OpenHuman to run agent nodes."),
+ message: format!(
+ "Inference unavailable: {error} Sign in to OpenHuman to run agent nodes."
+ ),
node_ids: vec![first_node_id.clone()],
}],
});
@@ -149,13 +146,23 @@ pub async fn evaluate(
tracing::debug!(target: "inference", nodes = ?node_ids, role, "probing inference readiness");
if let Err(message) = cached_probe(ctx, role, config).await {
tracing::warn!(target: "inference", nodes = ?node_ids, role, "inference readiness probe rejected: {message}");
- failures.push(ReadinessFailure { role, message, node_ids });
+ failures.push(ReadinessFailure {
+ role,
+ message,
+ node_ids,
+ });
}
}
if failures.is_empty() {
- return Some(ReadinessEvaluation { status: "ready", failures });
+ return Some(ReadinessEvaluation {
+ status: "ready",
+ failures,
+ });
}
- let statuses: Vec<_> = failures.iter().map(|failure| classify(&failure.message)).collect();
+ let statuses: Vec<_> = failures
+ .iter()
+ .map(|failure| classify(&failure.message))
+ .collect();
let status = if statuses.contains(&"signed_out") {
"signed_out"
} else if statuses.contains(&"provider_not_configured") {
diff --git a/crates/openhuman-core/src/inference/readiness_tests.rs b/crates/openhuman-core/src/inference/readiness_tests.rs
index 3b621e03f9..d570daadf0 100644
--- a/crates/openhuman-core/src/inference/readiness_tests.rs
+++ b/crates/openhuman-core/src/inference/readiness_tests.rs
@@ -48,10 +48,15 @@ async fn cached_probe_serves_definitive_negative_results() {
config.api_url = Some(format!("http://{addr}"));
let first = cached_probe(&DispatchCtx::ambient(), "summarization", &config).await;
- assert!(first.unwrap_err().to_ascii_lowercase().contains("api key not configured"));
+ assert!(first
+ .unwrap_err()
+ .to_ascii_lowercase()
+ .contains("api key not configured"));
assert_eq!(hit_count.load(Ordering::SeqCst), 1);
- assert!(cached_probe(&DispatchCtx::ambient(), "summarization", &config)
- .await
- .is_err());
+ assert!(
+ cached_probe(&DispatchCtx::ambient(), "summarization", &config)
+ .await
+ .is_err()
+ );
assert_eq!(hit_count.load(Ordering::SeqCst), 1);
}