Skip to content

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

feat(inference): add provider readiness checks for flow execution

Steven Enamakel2077b5125a12
diff --git a/crates/openhuman-core/src/flows/ops/builder_gates.rs b/crates/openhuman-core/src/flows/ops/builder_gates.rs
index 9adaf46f3b..fa471ec240 100644
--- a/crates/openhuman-core/src/flows/ops/builder_gates.rs
+++ b/crates/openhuman-core/src/flows/ops/builder_gates.rs
@@ -245,7 +245,7 @@ pub(crate) async fn build_builder_proposal(
// shared, cached evaluator the run-time preflight (`validate_inference_readiness`
// in `run_flow_body`) consumes, so a run right after this proposal reads
// the cached result instead of re-probing the network.
- let inference_readiness = evaluate_inference_readiness(config, graph).await;
+ let inference_readiness = evaluate_inference_readiness(ctx, config, graph).await;
let graph_value = serde_json::to_value(graph).map_err(|e| e.to_string())?;
tracing::info!(
diff --git a/crates/openhuman-core/src/flows/ops/execution.rs b/crates/openhuman-core/src/flows/ops/execution.rs
index fdad8f9011..37f4b79bab 100644
--- a/crates/openhuman-core/src/flows/ops/execution.rs
+++ b/crates/openhuman-core/src/flows/ops/execution.rs
@@ -173,7 +173,7 @@ async fn run_flow_body_inner(
// Returns an empty `Vec` (no-op here) for a tool_call-only graph, and is
// never consulted by `dry_run_workflow` (sandbox runs are exempt by
// design — that tool doesn't route through `run_flow_body` at all).
- let inference_errors = validate_inference_readiness(config, &flow.graph).await;
+ let inference_errors = validate_inference_readiness(&ctx, config, &flow.graph).await;
if !inference_errors.is_empty() {
let detail = inference_errors.join(" ");
let msg = format!("This flow's AI step needs a working AI provider to run. {detail}");
diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness.rs b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
index 83dbc1d116..7ed90dde25 100644
--- a/crates/openhuman-core/src/flows/ops/inference_readiness.rs
+++ b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
@@ -111,6 +111,7 @@ fn invalidate_inference_probe_cache_if_signed_out() {
}
pub(super) async fn cached_probe_inference_readiness(
+ ctx: &crate::core::runtime::DispatchCtx,
role: &str,
config: &Config,
) -> Result<(), String> {
@@ -135,7 +136,7 @@ pub(super) async fn cached_probe_inference_readiness(
}
}
- let result = crate::inference::provider::probe_inference_readiness(role, config).await;
+ let result = crate::inference::provider::probe_inference_readiness(ctx, role, config).await;
INFERENCE_PROBE_CACHE
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
@@ -264,6 +265,7 @@ pub(super) struct InferenceReadinessEvaluation {
/// from cache). `status`/`message` report `provider_not_configured`/`error`
/// if ANY role's probe fails, naming every offending node and role.
pub(super) async fn evaluate_inference_readiness(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
graph: &WorkflowGraph,
) -> Option<InferenceReadinessEvaluation> {
@@ -365,7 +367,7 @@ pub(super) async fn evaluate_inference_readiness(
role,
"[flows] inference-readiness: probing managed-backend/role readiness"
);
- if let Err(msg) = cached_probe_inference_readiness(role, config).await {
+ if let Err(msg) = cached_probe_inference_readiness(ctx, role, config).await {
tracing::warn!(
target: "flows",
nodes = ?node_ids,
@@ -467,10 +469,11 @@ pub(super) async fn evaluate_inference_readiness(
/// author from proposing/saving the graph in the first place. See the module
/// doc above for the two-layer evaluation design.
pub(crate) async fn validate_inference_readiness(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
graph: &WorkflowGraph,
) -> Vec<String> {
- let Some(evaluation) = evaluate_inference_readiness(config, graph).await else {
+ let Some(evaluation) = evaluate_inference_readiness(ctx, config, graph).await else {
return Vec::new();
};
if evaluation.status == "ready" {
diff --git a/crates/openhuman-core/src/inference/provider/factory.rs b/crates/openhuman-core/src/inference/provider/factory.rs
index 17f8a1a2ea..cf691b1659 100644
--- a/crates/openhuman-core/src/inference/provider/factory.rs
+++ b/crates/openhuman-core/src/inference/provider/factory.rs
@@ -56,7 +56,7 @@ mod turn_model;
pub(crate) use access_gates::current_host_requires_session;
pub(crate) use chat_model::resolves_to_managed_backend;
pub use chat_model::{
- create_chat_model, create_chat_model_from_string, create_chat_model_from_string_with_model_id,
+ create_chat_model_from_string, create_chat_model_from_string_with_model_id,
create_chat_model_with_model_id, create_chat_model_with_model_id_in, probe_inference_readiness,
};
pub(crate) use credentials::openai_bearer_is_oauth;
diff --git a/crates/openhuman-core/src/inference/provider/mod.rs b/crates/openhuman-core/src/inference/provider/mod.rs
index c9df66196c..fc464cfffb 100644
--- a/crates/openhuman-core/src/inference/provider/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/mod.rs
@@ -28,8 +28,8 @@ pub use error_code::{
#[cfg(feature = "flows")]
pub(crate) use factory::is_raw_passthrough_model;
pub use factory::{
- create_chat_model, create_chat_model_from_string, create_chat_model_from_string_with_model_id,
- create_chat_model_with_model_id, create_chat_model_with_model_id_in, probe_inference_readiness,
+ create_chat_model_from_string, create_chat_model_from_string_with_model_id,
+ create_chat_model_in, create_chat_model_with_model_id_in, probe_inference_readiness,
provider_for_role, role_for_model_tier, BYOK_INCOMPLETE_SENTINEL,
};
pub use openhuman_backend_model::{OpenHumanBackendModel, PROVIDER_LABEL};