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
test(inference): decouple provider tests from the built-in managed backend
Steven Enamakel5b71b6371add
diff --git a/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs b/crates/openhuman-core/src/flows/ops_inference_gate_tests.rsindex 8ec79a80fd..4d7a58fe5b 100644--- a/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs+++ b/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs@@ -247,9 +247,9 @@ async fn inference_gate_probes_every_distinct_agent_node_role() {"nodes": [{ "id": "t", "kind": "trigger", "name": "Manual" },{ "id": "a", "kind": "agent", "name": "Chat step",- "config": { "prompt": "chat", "model": "chat-v1" } },+ "config": { "prompt": "chat", "model": "hint:chat" } },{ "id": "b", "kind": "agent", "name": "Reasoning step",- "config": { "prompt": "reason", "model": "reasoning-v1" } }+ "config": { "prompt": "reason", "model": "hint:reasoning" } }],"edges": [{ "from_node": "t", "to_node": "a" },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.rsindex 710b0562ae..9e9aa58dac 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@@ -262,21 +262,18 @@ fn resolves_to_managed_backend_for_default_config_but_not_for_local() {#[test]fn create_chat_model_routes_managed_backend_to_crate_native() {let _guard = crate::inference::inference_test_guard();- // No test-provider override installed → the managed short-circuit engages.+ install_test_managed_provider();let config = Config::default();- let (model, _model_id) = create_chat_model_with_model_id_in(+ let (_model, model_id) = create_chat_model_with_model_id_in(&crate::core::runtime::DispatchCtx::ambient(),"chat",&config,0.7,).expect("managed create_chat_model must build");- assert_eq!(- model- .profile()- .and_then(|profile| profile.provider.as_deref()),- Some("managed"),- "managed backend must expose the crate-native managed profile"+ assert_eq!(model_id, "fixture/managed-default");+ crate::inference::registry::unregister_chat_model(+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,);}@@ -475,31 +472,27 @@ fn anthropic_auth_cloud_slug_in_text_mode_keeps_the_compat_client() {#[test]fn configured_openhuman_jwt_slug_routes_to_managed_chat_model() {let _guard = crate::inference::inference_test_guard();+ install_test_managed_provider();let mut config = Config::default();- config.cloud_providers.push(oh_entry("p_oh"));- // A retired tier slug after the managed slug is a role alias: it runs on- // the managed default, never reaches the backend verbatim.- config.chat_provider = Some("openhuman:reasoning-v1".to_string());+ config.cloud_providers.push(fixture_managed_entry("p_fixture"));+ config.chat_provider = Some("fixture-managed:hint:reasoning".to_string());let (model, model_id) =try_create_cloud_slug_chat_model("chat", &config, &EgressLedger::none())- .expect("configured OpenhumanJwt slug should be recognized")- .expect("managed model should build");+ .expect("registered host policy should recognize this route")+ .expect("registered model should build");- assert_eq!(model_id, "openrouter/deepseek/deepseek-v4-flash");+ assert_eq!(model_id, "fixture/managed-default");// A concrete catalog id is forwarded verbatim.- config.chat_provider = Some("openhuman:openrouter/deepseek/deepseek-v4-pro".to_string());+ config.chat_provider = Some("fixture-managed:vendor/pinned".to_string());let (_, pinned_id) = try_create_cloud_slug_chat_model("chat", &config, &EgressLedger::none())- .expect("configured OpenhumanJwt slug should be recognized")- .expect("managed model should build");- assert_eq!(pinned_id, "openrouter/deepseek/deepseek-v4-pro");- assert_eq!(- model- .profile()- .and_then(|profile| profile.provider.as_deref()),- Some("managed"),- "OpenhumanJwt must use the crate-native managed backend model"+ .expect("registered host policy should recognize this route")+ .expect("registered model should build");+ assert_eq!(pinned_id, "vendor/pinned");+ assert!(model.profile().is_none(), "the generic fixture has no host profile");+ crate::inference::registry::unregister_chat_model(+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,);}@@ -510,21 +503,22 @@ async fn openhuman_jwt_slug_discloses_pinned_model() {use std::time::Duration;let _guard = crate::inference::inference_test_guard_async().await;+ install_test_managed_provider();crate::core::bus::init().await.expect("bus init");let mut rx = crate::core::bus::BUS.get().unwrap().receiver();let marker = "egress-jwt-pinned-marker-v1";let mut config = Config::default();- config.cloud_providers.push(oh_entry("p_oh"));- let provider = format!("openhuman:{marker}");+ config.cloud_providers.push(fixture_managed_entry("p_fixture"));+ let provider = format!("fixture-managed:{marker}");let _ = try_create_cloud_slug_chat_model_from_string("chat",&provider,&config,&EgressLedger::none(),)- .expect("configured OpenhumanJwt slug should be recognized")- .expect("managed model should build");+ .expect("registered host policy should recognize this route")+ .expect("registered model should build");let sentinel = "egress-jwt-pinned-sentinel-end";crate::core::bus::BUS.publish(DomainEvent::ExternalTransferPending {@@ -555,6 +549,9 @@ async fn openhuman_jwt_slug_discloses_pinned_model() {count, 1,"JWT construction must disclose its pinned model once");+ crate::inference::registry::unregister_chat_model(+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,+ );}#[tokio::test]@@ -649,43 +646,46 @@ async fn native_claude_turn_routes_disclose_pinned_models() {#[test]fn openhuman_jwt_slug_preserves_forced_text_mode() {let _guard = crate::inference::inference_test_guard();+ let native_modes = install_test_managed_provider();let mut config = Config::default();- config.cloud_providers.push(oh_entry("p_oh"));+ config.cloud_providers.push(fixture_managed_entry("p_fixture"));- let (model, _) = try_create_cloud_slug_chat_model_from_string_with_native_tools(+ let (_model, _) = try_create_cloud_slug_chat_model_from_string_with_native_tools("chat",- "openhuman:reasoning-v1",+ "fixture-managed:hint:reasoning",&config,false,&EgressLedger::none(),)- .expect("configured OpenhumanJwt slug should be recognized")- .expect("managed model should build");+ .expect("registered host policy should recognize this route")+ .expect("registered model should build");- let profile = model- .profile()- .expect("managed model should expose its effective capabilities");- assert!(!profile.tool_calling);- assert!(!profile.parallel_tool_calls);- assert!(!profile.streaming_tool_chunks);+ assert_eq!(native_modes.lock().unwrap().as_slice(), [false]);+ crate::inference::registry::unregister_chat_model(+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,+ );}#[test]fn openhuman_jwt_slug_without_model_preserves_managed_role_tier() {let _guard = crate::inference::inference_test_guard();+ install_test_managed_provider();let mut config = Config::default();- config.cloud_providers.push(oh_entry("p_oh"));+ config.cloud_providers.push(fixture_managed_entry("p_fixture"));let (_model, model_id) = try_create_cloud_slug_chat_model_from_string("summarization",- "openhuman:",+ "fixture-managed:",&config,&EgressLedger::none(),)- .expect("configured OpenhumanJwt slug should be recognized")- .expect("managed model should build");+ .expect("registered host policy should recognize this route")+ .expect("registered model should build");- assert_eq!(model_id, "openrouter/deepseek/deepseek-v4-flash");+ assert_eq!(model_id, "fixture/managed-default");+ crate::inference::registry::unregister_chat_model(+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,+ );}#[test]diff --git a/crates/openhuman-core/src/inference/provider/factory_egress_fallback_tests.rs b/crates/openhuman-core/src/inference/provider/factory_egress_fallback_tests.rsindex 7ee479d810..42be0a5d37 100644--- a/crates/openhuman-core/src/inference/provider/factory_egress_fallback_tests.rs+++ b/crates/openhuman-core/src/inference/provider/factory_egress_fallback_tests.rs@@ -13,6 +13,7 @@ async fn create_chat_model_managed_emits_exactly_one_egress_realpath() {use std::time::Duration;let _guard = crate::inference::inference_test_guard_async().await;+ super::install_test_managed_provider();crate::core::bus::init().await.expect("bus init");let mut rx = crate::core::bus::BUS.get().unwrap().receiver();@@ -60,6 +61,9 @@ async fn create_chat_model_managed_emits_exactly_one_egress_realpath() {count, 1,"managed inference via create_chat_model_with_model_id must emit EXACTLY ONE egress descriptor (no miss, no double)");+ crate::inference::registry::unregister_chat_model(+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,+ );}/// Real-path smoke (privacy epic S2, #4436): a LOCAL runtime construction on thediff --git a/crates/openhuman-core/src/inference/provider/factory_tests.rs b/crates/openhuman-core/src/inference/provider/factory_tests.rsindex 051672c51a..187c460888 100644--- a/crates/openhuman-core/src/inference/provider/factory_tests.rs+++ b/crates/openhuman-core/src/inference/provider/factory_tests.rs@@ -4,6 +4,86 @@ use crate::config::Config;use crate::security::credentials::AuthService;use tempfile::TempDir;+#[cfg(test)]+struct ManagedRouteFixtureModel;++#[cfg(test)]+#[async_trait::async_trait]+impl ChatModel<()> for ManagedRouteFixtureModel {+ async fn invoke(+ &self,+ _state: &(),+ _request: tinyinference_llm::model::ModelRequest,+ ) -> tinyinference_llm::Result<tinyinference_llm::model::ModelResponse> {+ Ok(tinyinference_llm::model::ModelResponse::assistant("fixture"))+ }+}++#[cfg(test)]+fn install_test_managed_provider() -> Arc<std::sync::Mutex<Vec<bool>>> {+ use crate::config::schema::cloud_providers::AuthStyle;+ use crate::inference::registry::{ChatModelEntry, ProviderModelHooks};+ use std::sync::Mutex;++ let native_modes = Arc::new(Mutex::new(Vec::new()));+ let seen = Arc::clone(&native_modes);+ crate::inference::registry::register_chat_model(+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,+ ChatModelEntry {+ build: Arc::new(move |request| {+ seen.lock().unwrap().push(request.native_tool_calling);+ Ok((+ Arc::new(ManagedRouteFixtureModel),+ request+ .model_override+ .or(request.default_model)+ .unwrap_or("fixture/managed-default")+ .to_string(),+ ))+ }),+ probe: None,+ models: Some(ProviderModelHooks {+ default_model: Arc::new(|| Some("fixture/managed-default".into())),+ role_for_model: Arc::new(|model| {+ (model == "hint:reasoning").then(|| "reasoning".into())+ }),+ is_alias: Arc::new(|model| model == "hint:reasoning"),+ is_raw_model: Arc::new(|model| !model.starts_with("hint:")),+ supports_vision: Arc::new(|_| false),+ resolve_model: Arc::new(|_, config, model| match model {+ Some("hint:reasoning") => Some("fixture/managed-default".into()),+ Some(model) if !model.starts_with("hint:") => Some(model.into()),+ Some(_) => None,+ None => config+ .default_model+ .clone()+ .or_else(|| Some("fixture/managed-default".into())),+ }),+ context_window: Arc::new(|_| None),+ default_pricing: Arc::new(|| None),+ without_reasoning: Arc::new(|request| request),+ }),+ },+ );+ crate::config::schema::cloud_providers::register_hosted_cloud_provider_policy(+ Arc::new(|slug| slug == "fixture-managed"),+ Arc::new(|style| style == AuthStyle::OpenhumanJwt),+ );+ native_modes+}++#[cfg(test)]+fn fixture_managed_entry(id: &str) -> CloudProviderCreds {+ CloudProviderCreds {+ id: id.to_string(),+ slug: "fixture-managed".to_string(),+ label: "Managed fixture".to_string(),+ endpoint: "https://fixture.managed.test/v1".to_string(),+ auth_style: AuthStyle::OpenhumanJwt,+ default_model: Some("fixture/managed-default".into()),+ }+}+use crate::inference::provider::factory::access_gates::host_requires_session;fn create_test_chat_model_from_string(role: &str,diff --git a/crates/openhuman-core/src/inference/provider/http_error_tests.rs b/crates/openhuman-core/src/inference/provider/http_error_tests.rsindex dc9ad694e7..8a9b91dc6d 100644--- a/crates/openhuman-core/src/inference/provider/http_error_tests.rs+++ b/crates/openhuman-core/src/inference/provider/http_error_tests.rs@@ -11,6 +11,24 @@ fn response(status: StatusCode, body: &str) -> reqwest::Response {)}+const FIXTURE_BACKEND: &str = "fixture-managed-provider";++fn install_fixture_backend_classifier() {+ use crate::inference::registry::{+ register_backend_error_classifier, BackendErrorClassification,+ };+ register_backend_error_classifier(std::sync::Arc::new(|provider, _message| {+ BackendErrorClassification {+ provider_owned: provider == Some(FIXTURE_BACKEND),+ backend_owned: false,+ reportable: false,+ token: None,+ kind: None,+ malformed_bad_request: false,+ }+ }));+}+/// Drain the shared bus until `pick` matches an event or the queue is empty.fn drain_until<T>(rx: &mut tinybus::EventReceiver<DomainEvent>,@@ -82,10 +100,11 @@ async fn api_error_keeps_raw_message_for_unclassified_status() {#[tokio::test]async fn backend_401_publishes_session_expired_through_reporter() {+ install_fixture_backend_classifier();crate::core::bus::init().await.expect("bus init");let mut rx = crate::core::bus::BUS.get().expect("bus").receiver();let marker = "REPORTER_MARKER_SESSION";- let _ = api_error("OpenHuman", response(StatusCode::UNAUTHORIZED, marker)).await;+ let _ = api_error(FIXTURE_BACKEND, response(StatusCode::UNAUTHORIZED, marker)).await;let seen = drain_until(&mut rx, |e| match e {DomainEvent::SessionExpired { reason, .. } if reason.contains(marker) => Some(()),_ => None,@@ -121,10 +140,11 @@ async fn byo_401_publishes_api_key_rejected_not_session_expired() {#[tokio::test]async fn backend_provider_does_not_get_byo_key_rejection() {+ install_fixture_backend_classifier();crate::core::bus::init().await.expect("bus init");let mut rx = crate::core::bus::BUS.get().expect("bus").receiver();let _ = api_error(- "OpenHuman",+ FIXTURE_BACKEND,response(StatusCode::UNAUTHORIZED,r#"{"error":{"type":"authentication_error"}}"#,@@ -132,7 +152,7 @@ async fn backend_provider_does_not_get_byo_key_rejection() {).await;let rejected = drain_until(&mut rx, |e| match e {- DomainEvent::ProviderApiKeyRejected { provider, .. } if provider == "OpenHuman" => Some(()),+ DomainEvent::ProviderApiKeyRejected { provider, .. } if provider == FIXTURE_BACKEND => Some(()),_ => None,});assert!(@@ -146,7 +166,8 @@ async fn backend_provider_does_not_get_byo_key_rejection() {#[test]fn is_backend_auth_failure_only_matches_openhuman_backend_401_403() {use reqwest::StatusCode;- let backend = "OpenHuman";+ install_fixture_backend_classifier();+ let backend = FIXTURE_BACKEND;assert!(is_backend_auth_failure(backend, StatusCode::UNAUTHORIZED));assert!(is_backend_auth_failure(backend, StatusCode::FORBIDDEN));diff --git a/crates/openhuman-core/src/inference/provider/models/mod_tests.rs b/crates/openhuman-core/src/inference/provider/models/mod_tests.rsindex 26723bccc7..966a2fb194 100644--- a/crates/openhuman-core/src/inference/provider/models/mod_tests.rs+++ b/crates/openhuman-core/src/inference/provider/models/mod_tests.rs@@ -108,22 +108,26 @@ async fn unsupported_scheme_endpoint_still_surfaces_an_error() {assert!(result.is_err(), "ftp:// must not read as an empty catalog");}-/// With no catalog provider registered, the managed provider (by id, and by an-/// `OpenhumanJwt` entry) lists an empty catalog rather than failing.+/// A host-owned provider with no catalog may return an empty catalog. Passive+/// legacy auth classification is installed explicitly to exercise that path.#[tokio::test]async fn unregistered_managed_catalog_lists_no_models() {use crate::config::schema::cloud_providers::AuthStyle;+ use std::sync::Arc;++ crate::config::schema::cloud_providers::register_hosted_cloud_provider_policy(+ Arc::new(|slug| slug == "fixture-managed"),+ Arc::new(|style| style == AuthStyle::OpenhumanJwt),+ );let tmp = tempfile::tempdir().expect("tempdir");let config = workspace_with_provider(&tmp,- "custom-managed",+ "fixture-managed","https://managed.example/v1",AuthStyle::OpenhumanJwt,);- for provider in ["openhuman", "custom-managed"] {- let outcome = super::catalog_listing::list_configured_models_from_config(provider, &config)- .await- .expect("an unregistered managed catalog is empty, not an error");- assert_eq!(outcome.value["models"], serde_json::json!([]), "{provider}");- }+ let outcome = super::catalog_listing::list_configured_models_from_config("fixture-managed", &config)+ .await+ .expect("an unregistered host-owned catalog is empty, not an error");+ assert_eq!(outcome.value["models"], serde_json::json!([]));}diff --git a/crates/openhuman-core/src/inference/registry_tests.rs b/crates/openhuman-core/src/inference/registry_tests.rsindex 4910094e63..88a5c97a5e 100644--- a/crates/openhuman-core/src/inference/registry_tests.rs+++ b/crates/openhuman-core/src/inference/registry_tests.rs@@ -225,6 +225,10 @@ async fn a_registered_catalog_receives_the_entrys_provider_key() {use crate::config::schema::cloud_providers::{AuthStyle, CloudProviderCreds};use crate::config::schema::{EphemeralRoute, EPHEMERAL_ROUTE_SLUG};let seen = Arc::new(Mutex::new(String::new()));+ crate::config::schema::cloud_providers::register_hosted_cloud_provider_policy(+ Arc::new(|slug| slug == EPHEMERAL_ROUTE_SLUG),+ Arc::new(|style| style == AuthStyle::OpenhumanJwt),+ );let sink = Arc::clone(&seen);register_catalog(PROVIDER_OPENHUMAN,