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): add provider factory and registry test support
Steven Enamakel44d48c3ef010
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 199659ed36..ef9a0d87fc 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,7 +262,6 @@ 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();- let _managed = crate::inference::registry_test_support::FakeManaged::register();// No test-provider override installed → the managed short-circuit engages.let config = Config::default();let (model, _model_id) = create_chat_model_with_model_id_in(@@ -476,7 +475,6 @@ 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();- let _managed = crate::inference::registry_test_support::FakeManaged::register();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@@ -512,7 +510,6 @@ async fn openhuman_jwt_slug_discloses_pinned_model() {use std::time::Duration;let _guard = crate::inference::inference_test_guard_async().await;- let _managed = crate::inference::registry_test_support::FakeManaged::register();crate::core::bus::init().await.expect("bus init");let mut rx = crate::core::bus::BUS.get().unwrap().receiver();@@ -652,7 +649,6 @@ 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 _managed = crate::inference::registry_test_support::FakeManaged::register();let mut config = Config::default();config.cloud_providers.push(oh_entry("p_oh"));@@ -677,7 +673,6 @@ fn openhuman_jwt_slug_preserves_forced_text_mode() {#[test]fn openhuman_jwt_slug_without_model_preserves_managed_role_tier() {let _guard = crate::inference::inference_test_guard();- let _managed = crate::inference::registry_test_support::FakeManaged::register();let mut config = Config::default();config.cloud_providers.push(oh_entry("p_oh"));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 6a1cdd792c..7ee479d810 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,7 +13,6 @@ async fn create_chat_model_managed_emits_exactly_one_egress_realpath() {use std::time::Duration;let _guard = crate::inference::inference_test_guard_async().await;- let _managed = crate::inference::registry_test_support::FakeManaged::register();crate::core::bus::init().await.expect("bus init");let mut rx = crate::core::bus::BUS.get().unwrap().receiver();diff --git a/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rs b/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rsindex 3566f799f7..9349b85e84 100644--- a/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rs+++ b/crates/openhuman-core/src/inference/provider/factory_managed_ledger_tests.rs@@ -9,7 +9,6 @@ async fn managed_construction_ledger_collapses_repeat_disclosures() {use crate::core::events::DomainEvent;let _guard = crate::inference::inference_test_guard_async().await;- let _managed = crate::inference::registry_test_support::FakeManaged::register();crate::core::bus::init().await.expect("bus init");let mut rx = crate::core::bus::BUS.get().unwrap().receiver();diff --git a/crates/openhuman-core/src/inference/registry_test_support.rs b/crates/openhuman-core/src/inference/registry_test_support.rsindex 25adffeabf..97f31413d8 100644--- a/crates/openhuman-core/src/inference/registry_test_support.rs+++ b/crates/openhuman-core/src/inference/registry_test_support.rs@@ -1,18 +1,14 @@-//! Test support: a fake managed chat model registered under the managed-//! provider id, standing in for the hosted provider the core has no copy of.-//!-//! Registration is process-global, so callers hold-//! [`inference_test_guard`](crate::inference::inference_test_guard) (or its-//! async twin) for as long as the [`FakeManaged`] guard lives.+//! Test support: a fake managed chat model standing in for the hosted provider+//! the core has no copy of. [`chat_model`](super::registry) falls back to it in+//! unit tests, so the many tests that build a default-config agent keep+//! working; a test of the bare core opts out with [`without_managed_provider`].use std::sync::Arc;use async_trait::async_trait;use tinyinference_llm::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};-use super::registry::{- register_chat_model, unregister_chat_model, ChatModelEntry, ChatModelRequest,-};+use super::registry::{ChatModelEntry, ChatModelRequest};use crate::inference::provider::factory::PROVIDER_OPENHUMAN;/// A chat model whose profile mirrors the managed provider's (`managed`, with@@ -58,28 +54,6 @@ fn build(request: &ChatModelRequest<'_>) -> anyhow::Result<(Arc<dyn ChatModel<()Ok((Arc::new(model), resolved))}-/// Registers the fake for as long as the guard lives.-pub(crate) struct FakeManaged;--impl FakeManaged {- pub(crate) fn register() -> Self {- register_chat_model(- PROVIDER_OPENHUMAN,- ChatModelEntry {- build: Arc::new(build),- probe: None,- },- );- Self- }-}--impl Drop for FakeManaged {- fn drop(&mut self) {- unregister_chat_model(PROVIDER_OPENHUMAN);- }-}-thread_local! {static BARE_CORE: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };}