Skip to content

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

refactor(config): update builtin cloud provider access

Steven Enamakel353155853ab2
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 d32240c370..adf54235c8 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
@@ -3,7 +3,7 @@
use super::{
builtin_cloud_supports_responses_api, endpoint_host, endpoint_host_is_chat_completions_only,
host_is_builtin_cloud_provider, is_builtin_cloud_slug, is_slug_reserved, AuthStyle,
- BUILTIN_CLOUD_PROVIDERS,
+ builtin_cloud_providers,
};
#[test]
@@ -93,7 +93,7 @@ fn builtin_cloud_provider_defaults_cover_phase_one_presets() {
#[test]
fn builtin_cloud_provider_slugs_are_unique() {
let mut slugs = std::collections::HashSet::new();
- for provider in BUILTIN_CLOUD_PROVIDERS.iter() {
+ for provider in builtin_cloud_providers().iter() {
assert!(
slugs.insert(provider.slug),
"duplicate built-in cloud provider slug {}",
@@ -133,7 +133,7 @@ fn only_openai_builtin_exposes_responses_api() {
/// is the only built-in that serves `/v1/responses`.
#[test]
fn responses_api_capability_is_coupled_to_the_preset_list() {
- for provider in BUILTIN_CLOUD_PROVIDERS.iter() {
+ for provider in builtin_cloud_providers().iter() {
let expected = provider.slug == "openai";
assert_eq!(
builtin_cloud_supports_responses_api(provider.slug),
@@ -198,7 +198,7 @@ fn host_is_builtin_cloud_provider_recognises_inference_hosts() {
);
}
// Every registry endpoint's own host must classify as builtin.
- for provider in BUILTIN_CLOUD_PROVIDERS.iter() {
+ for provider in builtin_cloud_providers().iter() {
let host = endpoint_host(provider.endpoint).expect("preset endpoint has a host");
assert!(
host_is_builtin_cloud_provider(&host),
@@ -256,7 +256,7 @@ fn openai_host_and_unknown_proxies_keep_the_responses_fallback() {
/// can't silently desync the two gates.
#[test]
fn host_gate_agrees_with_slug_capability_for_every_builtin() {
- for provider in BUILTIN_CLOUD_PROVIDERS.iter() {
+ for provider in builtin_cloud_providers().iter() {
// OpenhumanJwt / Anthropic presets never route through the
// OpenAI-compatible Responses fallback; the gate only matters for
// the Bearer OpenAI-compatible hosts.
@@ -300,7 +300,7 @@ fn generated_provider_ids_sanitize_and_bound_the_slug_prefix() {
#[test]
fn builtin_table_is_the_upstream_catalog_plus_the_managed_route() {
use tinyinference_providers::builtin::BUILTIN_CLOUD_PROVIDERS as UPSTREAM;
- let host = &*BUILTIN_CLOUD_PROVIDERS;
+ let host = builtin_cloud_providers();
assert_eq!(host.len(), UPSTREAM.len() + 1);
assert_eq!(host[0].slug, "openhuman");
assert_eq!(host[0].auth_style, AuthStyle::OpenhumanJwt);
diff --git a/crates/openhuman-core/src/config/schema/load/migrate.rs b/crates/openhuman-core/src/config/schema/load/migrate.rs
index 663092378e..80a0038b57 100644
--- a/crates/openhuman-core/src/config/schema/load/migrate.rs
+++ b/crates/openhuman-core/src/config/schema/load/migrate.rs
@@ -71,9 +71,8 @@ pub(crate) fn migrate_cloud_provider_slugs(config: &mut Config) {
for entry in &mut config.cloud_providers {
if entry.label.is_empty() {
entry.label = builtin_cloud_provider(&entry.slug)
- .map(|provider| provider.label)
- .unwrap_or("Custom")
- .to_string();
+ .map(|provider| provider.label.to_string())
+ .unwrap_or_else(|| "Custom".to_string());
}
}
diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs
index 4a4d425b63..15bce6e6c8 100644
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_spec_tests.rs
@@ -57,7 +57,7 @@ fn managed_jwt_style_never_maps_onto_the_registry() {
#[test]
fn registry_builds_a_model_for_every_unmanaged_builtin_preset() {
- for preset in crate::config::schema::cloud_providers::BUILTIN_CLOUD_PROVIDERS.iter() {
+ for preset in crate::config::schema::cloud_providers::builtin_cloud_providers().iter() {
if preset.auth_style == AuthStyle::OpenhumanJwt {
continue;
}