Skip to content

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

refactor(inference): adjust provider factory logic and model resolution

Steven Enamakel3a6bbcecdf42
diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
index 84e7b3359f..21efdca502 100644
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
@@ -392,7 +392,11 @@ pub(super) fn try_create_cloud_slug_chat_model_from_string_with_native_tools_for
);
}
AuthStyle::Anthropic | AuthStyle::None => {}
- style if crate::config::schema::cloud_providers::is_hosted_auth_style_for(extensions, style) => {
+ style
+ if crate::config::schema::cloud_providers::is_hosted_auth_style_for(
+ extensions, style,
+ ) =>
+ {
#[cfg(not(test))]
if let Err(error) = verify_backend_session_active(config) {
return Some(Err(error));
diff --git a/crates/openhuman-core/src/inference/provider/factory/discovery.rs b/crates/openhuman-core/src/inference/provider/factory/discovery.rs
index 06515a43a4..6eb9636819 100644
--- a/crates/openhuman-core/src/inference/provider/factory/discovery.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/discovery.rs
@@ -50,7 +50,10 @@ pub(crate) fn model_limits_request_for(
let (slug, raw) = p.split_once(':')?;
let slug = slug.trim();
let entry = config.cloud_providers.iter().find(|e| e.slug == slug)?;
- if crate::config::schema::cloud_providers::is_hosted_auth_style_for(extensions, entry.auth_style) {
+ if crate::config::schema::cloud_providers::is_hosted_auth_style_for(
+ extensions,
+ entry.auth_style,
+ ) {
let (raw_model, _) = split_model_and_temperature(raw);
let model = if raw_model.trim().is_empty() {
model
diff --git a/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs b/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs
index c137e5eabb..169012b1f2 100644
--- a/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_explicit_ctx_tests.rs
@@ -67,6 +67,18 @@ async fn managed_factory_and_probe_use_the_explicit_provider_entry() {
let (_, model) = create_chat_model_with_model_id_in(&dispatch, "chat", &config, 0.0)
.expect("explicit model entry builds");
assert_eq!(model, "context-a-one-shot");
+ let simple_chat =
+ crate::inference::host_runtime::ops::agent_chat_simple::agent_chat_simple(
+ &dispatch,
+ &config,
+ "fixture prompt",
+ None,
+ None,
+ None,
+ )
+ .await
+ .expect("simple chat uses its explicit model entry");
+ assert_eq!(simple_chat.value, "context-a-one-shot");
let simple = crate::inference::host_runtime::ops::agent_chat_simple::agent_chat_simple(
&dispatch,
&config,
@@ -160,9 +172,7 @@ async fn hosted_cloud_slug_uses_explicit_auth_policy_and_model_entry() {
fn catalog(name: &'static str) -> CatalogEntry {
CatalogEntry {
list: Arc::new(|_, _| {
- Box::pin(async {
- Err("model listing is not used by this test".to_string())
- })
+ Box::pin(async { Err("model listing is not used by this test".to_string()) })
}),
limits: Some(Arc::new(move |model, _| {
Some(tinyinference_llm::model::discover::DiscoveryRequest {
diff --git a/crates/openhuman-core/src/inference/provider_model.rs b/crates/openhuman-core/src/inference/provider_model.rs
index c24ebd860f..28c91db5e2 100644
--- a/crates/openhuman-core/src/inference/provider_model.rs
+++ b/crates/openhuman-core/src/inference/provider_model.rs
@@ -33,9 +33,9 @@ fn role_for_provider_model_with(
.filter(|role| WORKLOAD_ROLES.contains(role))
.map(str::to_string)
.or_else(|| match extensions {
- Some(extensions) => crate::inference::registry::provider_model_role_for(
- extensions, provider_id, model,
- ),
+ Some(extensions) => {
+ crate::inference::registry::provider_model_role_for(extensions, provider_id, model)
+ }
None => crate::inference::registry::provider_model_role(provider_id, model),
});
role.as_deref()
@@ -63,11 +63,7 @@ pub(crate) fn is_abstract_model_for(
model: &str,
) -> bool {
model.trim().starts_with("hint:")
- || crate::inference::registry::provider_model_is_alias_for(
- extensions,
- provider_id,
- model,
- )
+ || crate::inference::registry::provider_model_is_alias_for(extensions, provider_id, model)
}
/// Resolve a model hint according to the configured provider route and the
@@ -133,8 +129,7 @@ fn resolve_provider_model_hint_with(
Some(trimmed),
),
};
- return resolved
- .unwrap_or_else(|| trimmed.to_string());
+ return resolved.unwrap_or_else(|| trimmed.to_string());
}
if let Some((_, model)) = route.split_once(':') {
return tinyinference_providers::route::split_model_and_temperature(model).0;
diff --git a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
index f306ba9859..a7d10c0eb3 100644
--- a/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
+++ b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
@@ -86,9 +86,7 @@ pub(super) fn handle_inference_resolve_model(
// tier; custom/BYOK models are covered by the user's per-model
// `model_registry.vision` flag.
let vision = crate::inference::model_context::model_supports_vision_in(
- extensions,
- &resolved,
- &config,
+ extensions, &resolved, &config,
);
to_json(Outcome::new(
serde_json::json!({ "model": resolved, "vision": vision }),
diff --git a/crates/openhuman-core/src/inference/turn_models_tests.rs b/crates/openhuman-core/src/inference/turn_models_tests.rs
index d1d782d019..d1ef84cf77 100644
--- a/crates/openhuman-core/src/inference/turn_models_tests.rs
+++ b/crates/openhuman-core/src/inference/turn_models_tests.rs
@@ -83,6 +83,7 @@ async fn explicit_turn_context_uses_its_model_and_capabilities_over_ambient_cont
assert_eq!(name_of(&models.primary).await, "context-a-model");
assert_eq!(name_of(&models.summarizer).await, "context-a-model");
+ assert_eq!(name_of(&models.summarizer).await, "context-a-model");
assert!(models
.primary
.profile()