Skip to content

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

test(inference): add readiness tests module and update error assertion

Steven Enamakel08411314bbc7
diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness.rs b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
index aea226515c..36205ff114 100644
--- a/crates/openhuman-core/src/flows/ops/inference_readiness.rs
+++ b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
@@ -153,3 +153,7 @@ pub(crate) async fn validate_inference_readiness(
vec![message]
}
}
+
+#[cfg(test)]
+#[path = "inference_readiness_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness_tests.rs b/crates/openhuman-core/src/flows/ops/inference_readiness_tests.rs
new file mode 100644
index 0000000000..93aa698da7
--- /dev/null
+++ b/crates/openhuman-core/src/flows/ops/inference_readiness_tests.rs
@@ -0,0 +1,51 @@
+use super::*;
+
+#[test]
+fn signed_out_projection_preserves_the_session_error_without_flow_prefix() {
+ let evaluation = crate::inference::readiness::ReadinessEvaluation {
+ status: "signed_out",
+ failures: vec![crate::inference::readiness::ReadinessFailure {
+ status: "signed_out",
+ session_wide: true,
+ role: "chat",
+ message: "Inference unavailable: you are signed out. Sign in to OpenHuman to run agent nodes.".into(),
+ node_ids: vec!["agent-1".into()],
+ }],
+ };
+ assert_eq!(
+ format_evaluation(&evaluation).as_deref(),
+ Some("Inference unavailable: you are signed out. Sign in to OpenHuman to run agent nodes.")
+ );
+}
+
+#[test]
+fn mixed_failures_keep_per_role_guidance_order_and_failure_count() {
+ let evaluation = crate::inference::readiness::ReadinessEvaluation {
+ status: "signed_out",
+ failures: vec![
+ crate::inference::readiness::ReadinessFailure {
+ status: "signed_out",
+ session_wide: false,
+ role: "chat",
+ message: "session_expired".into(),
+ node_ids: vec!["agent-chat".into()],
+ },
+ crate::inference::readiness::ReadinessFailure {
+ status: "provider_not_configured",
+ session_wide: false,
+ role: "reasoning",
+ message: "API key not configured for provider".into(),
+ node_ids: vec!["agent-reasoning".into()],
+ },
+ ],
+ };
+ let message = format_evaluation(&evaluation).expect("failures produce a message");
+ assert!(message.starts_with("This flow has 2 agent step(s) that need a working AI provider:"));
+ let chat = message.find("role `chat`").unwrap();
+ let reasoning = message.find("role `reasoning`").unwrap();
+ assert!(
+ chat < reasoning,
+ "roles retain deterministic order: {message}"
+ );
+ assert!(message.contains("Configure your provider API key in OpenHuman Settings > Providers"));
+}
diff --git a/crates/openhuman-core/src/inference/readiness_tests.rs b/crates/openhuman-core/src/inference/readiness_tests.rs
index d570daadf0..4622662ae6 100644
--- a/crates/openhuman-core/src/inference/readiness_tests.rs
+++ b/crates/openhuman-core/src/inference/readiness_tests.rs
@@ -51,7 +51,7 @@ async fn cached_probe_serves_definitive_negative_results() {
assert!(first
.unwrap_err()
.to_ascii_lowercase()
- .contains("api key not configured"));
+ .contains("api key not configured for provider"));
assert_eq!(hit_count.load(Ordering::SeqCst), 1);
assert!(
cached_probe(&DispatchCtx::ambient(), "summarization", &config)