Skip to content

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

chore: files changed crates/openhuman-core/src/config/schema/cloud_providers.rs,crates/openhuman-cor

Steven Enamakelba885c736a14
diff --git a/crates/openhuman-core/src/config/schema/cloud_providers.rs b/crates/openhuman-core/src/config/schema/cloud_providers.rs
index fdce83d2b2..c46a8e6f44 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers.rs
@@ -122,23 +122,17 @@ pub fn builtin_cloud_providers() -> Vec<BuiltinCloudProvider> {
// Keep the product's managed entry first for settings presentation. The
// owner catalog itself remains generic-first for exact-slug lookup.
hosted
- .into_iter()
- .chain(
- UPSTREAM_BUILTINS
+ .iter()
+ .copied()
+ .filter(|preset| {
+ !UPSTREAM_BUILTINS
.iter()
- .filter(|preset| !hosted_has_slug(preset.slug))
- .map(BuiltinCloudProvider::from),
- )
+ .any(|generic| generic.slug == preset.slug)
+ })
+ .chain(UPSTREAM_BUILTINS.iter().map(BuiltinCloudProvider::from))
.collect::<Vec<_>>()
}
-fn hosted_has_slug(slug: &str) -> bool {
- HOSTED_PRESETS
- .entries_context_first()
- .iter()
- .any(|(_, preset)| preset.slug == slug)
-}
-
/// Generic provider catalog extended with the host's registered preset
/// metadata. Host auth policy remains in the owning host registry.
pub fn builtin_presets() -> BuiltinPresets {
@@ -164,6 +158,9 @@ pub fn builtin_presets() -> BuiltinPresets {
}
pub fn builtin_cloud_provider(type_str: &str) -> Option<BuiltinCloudProvider> {
+ if let Some(preset) = BuiltinPresets::default().builtin_cloud_provider(type_str) {
+ return Some(BuiltinCloudProvider::from(preset));
+ }
let hosted = HOSTED_PRESETS
.entries_context_first()
.into_iter()
@@ -172,9 +169,7 @@ pub fn builtin_cloud_provider(type_str: &str) -> Option<BuiltinCloudProvider> {
if let Some(preset) = hosted.iter().find(|preset| preset.slug == type_str) {
return Some(*preset);
}
- BuiltinPresets::default()
- .builtin_cloud_provider(type_str)
- .map(BuiltinCloudProvider::from)
+ None
}
/// Whether `host` is the authority host of any built-in cloud **inference**
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 2fb5d0746f..99baeef10b 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
@@ -144,6 +144,16 @@ fn hosted_presets_and_classification_are_context_scoped() {
auth_style: AuthStyle::Bearer,
},
);
+ super::register_hosted_cloud_preset_in(
+ &extensions,
+ "host-openai",
+ super::BuiltinCloudProvider {
+ slug: "openai",
+ label: "Host OpenAI Override",
+ endpoint: "https://override.example/v1",
+ auth_style: AuthStyle::Anthropic,
+ },
+ );
super::register_hosted_cloud_provider_policy_in(
&extensions,
std::sync::Arc::new(|slug| slug == "tenant-hosted"),
@@ -162,6 +172,12 @@ fn hosted_presets_and_classification_are_context_scoped() {
assert_eq!(presets[0].label, "Tenant Hosted");
assert_eq!(presets[0].endpoint, "https://tenant.example/v1");
assert!(presets.iter().any(|preset| preset.slug == "openai"));
+ assert_eq!(presets.iter().filter(|preset| preset.slug == "openai").count(), 1);
+ assert_eq!(
+ super::builtin_cloud_provider("openai").unwrap().endpoint,
+ "https://api.openai.com/v1",
+ "host additions must not replace a generic provider"
+ );
assert!(super::builtin_presets().host_is_builtin_cloud_provider("tenant.example"));
assert!(super::builtin_presets().endpoint_host_is_chat_completions_only(
"https://tenant.example/v1"