Skip to content

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

refactor(inference): clean up model source logic and tests

Steven Enamakelcf32c0f0e0fd
diff --git a/crates/openhuman-core/src/core/runtime/context_test_support.rs b/crates/openhuman-core/src/core/runtime/context_test_support.rs
index 2dfe2064c1..c78bca3c86 100644
--- a/crates/openhuman-core/src/core/runtime/context_test_support.rs
+++ b/crates/openhuman-core/src/core/runtime/context_test_support.rs
@@ -71,8 +71,8 @@ impl CoreContext {
domains,
workspace_dir,
))
- .ok()
- .unwrap();
+ .ok()
+ .unwrap();
ctx.extensions = extensions;
Arc::new(ctx)
}
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.rs
index e1f581ff37..bb5f0c0e28 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
@@ -214,10 +214,8 @@ async fn one_shot_cloud_sentinel_resolves_the_configured_byok_provider() {
let _guard = crate::inference::inference_test_guard_async().await;
let _env = crate::config::TEST_ENV_LOCK.lock().await;
let tmp = tempfile::tempdir().expect("isolated workspace");
- let mut config = config_with_providers_in_tempdir(
- &tmp,
- vec![openai_entry("p_openai", "openai")],
- );
+ let mut config =
+ config_with_providers_in_tempdir(&tmp, vec![openai_entry("p_openai", "openai")]);
config.chat_provider = Some("openai:gpt-4o-mini".into());
store_byo_key(&config, "openai", "sk-fixture");
let library = crate::core::runtime::CoreContext::for_test_with_host_kind(
@@ -228,13 +226,9 @@ async fn one_shot_cloud_sentinel_resolves_the_configured_byok_provider() {
crate::core::runtime::CoreContext::scope(library, async {
for provider in ["cloud", ""] {
- let (_, model) = create_chat_model_from_string_with_model_id(
- "chat",
- provider,
- &config,
- 0.2,
- )
- .expect("sentinel resolves to the configured BYOK route");
+ let (_, model) =
+ create_chat_model_from_string_with_model_id("chat", provider, &config, 0.2)
+ .expect("sentinel resolves to the configured BYOK route");
assert_eq!(model, "gpt-4o-mini");
}
})
diff --git a/crates/openhuman-core/src/inference/turn_models.rs b/crates/openhuman-core/src/inference/turn_models.rs
index 4b171fdeff..71a030289d 100644
--- a/crates/openhuman-core/src/inference/turn_models.rs
+++ b/crates/openhuman-core/src/inference/turn_models.rs
@@ -507,7 +507,11 @@ impl TurnModelSource {
// the wall-clock ceilings use endpoint-aware self-hosted detection.
let (provider_id, native_tools, supports_vision, is_local, self_hosted, context_window) =
if let Some(profile) = injected_profile {
- let provider_id = profile.provider.as_deref().unwrap_or("injected").to_string();
+ let provider_id = profile
+ .provider
+ .as_deref()
+ .unwrap_or("injected")
+ .to_string();
(
provider_id.clone(),
profile.tool_calling,
@@ -523,14 +527,15 @@ impl TurnModelSource {
context_window.or(profile.max_input_tokens),
)
} else {
- let is_local = tinyinference_local::profile::is_local_provider_string(
- &provider_string,
- );
+ let is_local =
+ tinyinference_local::profile::is_local_provider_string(&provider_string);
let self_hosted =
crate::agent::tinyagents::turn_policy::provider_is_self_hosted(
&provider_string,
- crate::agent::tinyagents::turn_policy::local_openai_endpoint(&cn.config)
- .as_deref(),
+ crate::agent::tinyagents::turn_policy::local_openai_endpoint(
+ &cn.config,
+ )
+ .as_deref(),
);
let provider_id = if provider_string == "openhuman"
|| provider_string.is_empty()
diff --git a/crates/openhuman-core/src/inference/turn_models_tests.rs b/crates/openhuman-core/src/inference/turn_models_tests.rs
index 73f0a0aa36..fa42a6be18 100644
--- a/crates/openhuman-core/src/inference/turn_models_tests.rs
+++ b/crates/openhuman-core/src/inference/turn_models_tests.rs
@@ -263,11 +263,8 @@ async fn explicit_provider_string_turn_source_uses_scoped_managed_model() {
None,
explicit_extensions,
);
- let ambient_context = CoreContext::for_test_with_host_kind(
- HostKind::Library,
- DomainSet::full(),
- None,
- );
+ let ambient_context =
+ CoreContext::for_test_with_host_kind(HostKind::Library, DomainSet::full(), None);
let dispatch = DispatchCtx::new(explicit_context);
let mut config = crate::config::Config::default();
config.chat_provider = Some("unconfigured:must-not-win".into());
@@ -293,8 +290,8 @@ async fn injected_turn_profile_is_authoritative_and_skips_unselected_routes() {
use crate::core::runtime::{ContextOverlay, CoreContext, DispatchCtx, DomainSet};
use crate::core::slots::Extensions;
use crate::core::types::HostKind;
- use tinyinference_llm::model::ModelProfile;
use std::sync::atomic::{AtomicUsize, Ordering};
+ use tinyinference_llm::model::ModelProfile;
struct ProfiledModel {
profile: ModelProfile,