Skip to content

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

refactor(config): simplify cloud provider hosting checks

Steven Enamakel68204dcd883e
diff --git a/crates/openhuman-core/src/channels/routes.rs b/crates/openhuman-core/src/channels/routes.rs
index d0b1479828..243af8d25f 100644
--- a/crates/openhuman-core/src/channels/routes.rs
+++ b/crates/openhuman-core/src/channels/routes.rs
@@ -16,8 +16,9 @@ fn provider_descriptors(config: &crate::config::Config) -> Vec<ProviderDescripto
name: provider.slug.clone(),
aliases: if crate::config::schema::cloud_providers::is_hosted_cloud_identity(
&provider.slug,
- ) || crate::config::schema::cloud_providers::is_hosted_auth_style(provider.auth_style)
- {
+ ) || crate::config::schema::cloud_providers::is_hosted_auth_style(
+ provider.auth_style,
+ ) {
vec!["backend".to_string(), "openhuman-backend".to_string()]
} else {
Vec::new()
diff --git a/crates/openhuman-core/src/config/schema/cloud_providers.rs b/crates/openhuman-core/src/config/schema/cloud_providers.rs
index f45b246b11..f7ba144dd6 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers.rs
@@ -84,11 +84,6 @@ pub fn is_hosted_auth_style(style: AuthStyle) -> bool {
.is_some_and(|classify| classify(style))
}
-/// Whether either the provider identity or auth style routes through the host.
-pub fn is_hosted_cloud_provider(slug: &str, style: AuthStyle) -> bool {
- is_hosted_cloud_identity(slug) || is_hosted_auth_style(style)
-}
-
impl From<&'static tinyinference_providers::builtin::BuiltinCloudProvider>
for BuiltinCloudProvider
{
diff --git a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
index 4abc8c8e8f..53557ac004 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
@@ -155,22 +155,13 @@ fn hosted_presets_and_classification_are_context_scoped() {
assert!(super::builtin_cloud_provider("tenant-hosted").is_none());
crate::core::runtime::CoreContext::sync_scope(context, || {
assert!(super::builtin_cloud_provider("tenant-hosted").is_some());
- assert!(super::is_hosted_cloud_provider(
- "tenant-hosted",
- AuthStyle::Bearer
- ));
assert!(super::is_hosted_cloud_identity("tenant-hosted"));
assert!(!super::is_hosted_auth_style(AuthStyle::Bearer));
- assert!(!super::is_hosted_cloud_provider(
- "openai",
- AuthStyle::Bearer
- ));
+ assert!(super::is_hosted_auth_style(AuthStyle::OpenhumanJwt));
});
assert!(super::builtin_cloud_provider("tenant-hosted").is_none());
- assert!(!super::is_hosted_cloud_provider(
- "tenant-hosted",
- AuthStyle::Bearer
- ));
+ assert!(!super::is_hosted_cloud_identity("tenant-hosted"));
+ assert!(!super::is_hosted_auth_style(AuthStyle::OpenhumanJwt));
}
/// Drift guard (TAURI-RUST-5EN): couple the capability helper to the
diff --git a/crates/openhuman-core/src/inference/provider/models/catalog_listing_tests.rs b/crates/openhuman-core/src/inference/provider/models/catalog_listing_tests.rs
index 13b7089e7b..d0dc7aa2ed 100644
--- a/crates/openhuman-core/src/inference/provider/models/catalog_listing_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/models/catalog_listing_tests.rs
@@ -40,6 +40,22 @@ async fn list_models_valid_json_still_succeeds() {
assert_eq!(outcome.value["models"][0]["id"], "some-model");
}
+#[tokio::test]
+async fn unregistered_legacy_auth_style_fails_before_catalog_network_request() {
+ let tmp = tempfile::tempdir().expect("tempdir");
+ let mut config = configure_generic_workspace(&tmp, "http://127.0.0.1:0/v1".to_string()).await;
+ config.cloud_providers[0].auth_style = AuthStyle::OpenhumanJwt;
+
+ let error = catalog_listing::list_configured_models_from_config("generic-test", &config)
+ .await
+ .expect_err("an unadapted legacy auth style must fail closed");
+
+ assert!(
+ error.contains("hosted cloud catalog is unavailable"),
+ "{error}"
+ );
+}
+
#[tokio::test]
async fn list_models_uses_provider_ca_bundle_client() {
let tmp = tempfile::tempdir().expect("tempdir");
diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rs
index d3436a44ad..ef55c7c0f3 100644
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@ -137,8 +137,7 @@ pub mod config {
pub mod cloud_providers {
pub use openhuman_core::config::schema::cloud_providers::{
builtin_cloud_provider, endpoint_host, generate_provider_id,
- host_is_builtin_cloud_provider, is_hosted_auth_style,
- is_hosted_cloud_identity, is_hosted_cloud_provider,
+ host_is_builtin_cloud_provider, is_hosted_auth_style, is_hosted_cloud_identity,
register_hosted_cloud_preset, register_hosted_cloud_preset_in,
register_hosted_cloud_provider_policy, register_hosted_cloud_provider_policy_in,
AuthStyle, BuiltinCloudProvider, CloudProviderCreds, HostedAuthStyleClassifier,
diff --git a/crates/openhuman-tinyhumans/src/hosted_config_tests.rs b/crates/openhuman-tinyhumans/src/hosted_config_tests.rs
index 0017ef1173..e7ac9ee8f5 100644
--- a/crates/openhuman-tinyhumans/src/hosted_config_tests.rs
+++ b/crates/openhuman-tinyhumans/src/hosted_config_tests.rs
@@ -12,15 +12,23 @@ fn hosted_openhuman_preset_and_legacy_auth_policy_are_registered_before_config_l
assert_eq!(preset.auth_style, AuthStyle::OpenhumanJwt);
assert!(
- openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_provider(
- "openhuman",
- AuthStyle::Bearer,
+ openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_identity(
+ "openhuman"
+ )
+ );
+ assert!(
+ !openhuman_embed::__host::config::schema::cloud_providers::is_hosted_auth_style(
+ AuthStyle::Bearer
+ )
+ );
+ assert!(
+ !openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_identity(
+ "legacy-custom-slug"
)
);
assert!(
- openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_provider(
- "legacy-custom-slug",
- AuthStyle::OpenhumanJwt,
+ openhuman_embed::__host::config::schema::cloud_providers::is_hosted_auth_style(
+ AuthStyle::OpenhumanJwt
)
);
assert!(
diff --git a/crates/openhuman-tinyhumans/src/inference/mod.rs b/crates/openhuman-tinyhumans/src/inference/mod.rs
index 83b5dfe1ca..c15bdb94b0 100644
--- a/crates/openhuman-tinyhumans/src/inference/mod.rs
+++ b/crates/openhuman-tinyhumans/src/inference/mod.rs
@@ -28,9 +28,8 @@ use std::sync::Arc;
use openhuman_embed::__host::config::Config;
use openhuman_embed::__host::inference_registry::{
register_backend_error_classifier, register_catalog, register_chat_model,
- register_config_normalizer, register_embedding, BackendErrorClassification, BackendErrorKind,
- BoxFuture, ChatModelEntry, ChatModelFactory, ChatModelRequest, ProviderModelHooks,
- ReadinessProbe, PROVIDER_OPENHUMAN,
+ register_config_normalizer, register_embedding, BoxFuture, ChatModelEntry, ChatModelFactory,
+ ChatModelRequest, ProviderModelHooks, ReadinessProbe, PROVIDER_OPENHUMAN,
};
use tinyinference_llm::model::ChatModel;