Skip to content

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

refactor(backend): update backend URL logic for hosted providers

Steven Enamakel21624daa8e90
diff --git a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
index ee08bf337b..4152da4a5f 100644
--- a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
+++ b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs
@@ -83,7 +83,8 @@ fn effective_embedder_slug_from_config(config: &Config) -> &'static str {
fn active_custom_profile(config: &Config) -> Option<crate::config::schema::CustomEmbeddingsConfig> {
let (_, endpoint) = split_custom_provider(&config.memory.embedding_provider);
- let endpoint = endpoint?.trim();
+ let endpoint = endpoint?;
+ let endpoint = endpoint.trim();
if endpoint.is_empty() {
return None;
}
@@ -146,7 +147,7 @@ pub async fn get_settings(config: &Config) -> Result<Outcome<serde_json::Value>,
.collect();
let vector_search_enabled = {
- let (slug, endpoint) = split_custom_provider(provider);
+ let (_, endpoint) = split_custom_provider(provider);
let slug = if endpoint.is_some() {
"custom"
} else {
diff --git a/crates/openhuman-tinyhumans/src/backend/url.rs b/crates/openhuman-tinyhumans/src/backend/url.rs
index 43526a4af1..59e09c0893 100644
--- a/crates/openhuman-tinyhumans/src/backend/url.rs
+++ b/crates/openhuman-tinyhumans/src/backend/url.rs
@@ -162,7 +162,16 @@ pub fn effective_backend_api_url(api_url: &Option<String>) -> String {
// billing) would 400/404 against the inference host — TAURI-RUST-HW1
// (4932 `GET /teams/me/usage` 400s from `openrouter.ai`). Cloud analogue
// of the local-AI guard (OPENHUMAN-TAURI-51/-80/-7Z, Ollama).
- let presets = tinyinference_providers::builtin::BuiltinPresets::default();
+ let hosted = crate::hosted_config::openhuman_preset();
+ let presets = tinyinference_providers::builtin::BuiltinPresets::new([
+ tinyinference_providers::builtin::BuiltinCloudProvider {
+ slug: hosted.slug,
+ label: hosted.label,
+ endpoint: hosted.endpoint,
+ // Used only for host classification, never for authentication.
+ auth_style: tinyinference_providers::builtin::BuiltinAuthStyle::Bearer,
+ },
+ ]);
let is_cloud_inference = presets
.endpoint_host(u)
.is_some_and(|host| presets.host_is_builtin_cloud_provider(&host));
diff --git a/crates/openhuman-tinyhumans/src/backend/url_tests.rs b/crates/openhuman-tinyhumans/src/backend/url_tests.rs
index 33f94256be..7828e7cceb 100644
--- a/crates/openhuman-tinyhumans/src/backend/url_tests.rs
+++ b/crates/openhuman-tinyhumans/src/backend/url_tests.rs
@@ -462,6 +462,24 @@ fn backend_url_falls_back_for_cloud_inference_base() {
);
}
+#[test]
+fn backend_url_recognizes_hosted_openhuman_inference_host() {
+ let _guard = env_lock();
+ let _env = EnvSnapshot::clear_backend_env();
+ let fallback = fallback_backend_base_for_current_build();
+
+ for api_url in [
+ "https://api.openhuman.ai/v1",
+ "https://api.openhuman.ai/custom/inference",
+ ] {
+ assert_eq!(
+ effective_backend_api_url(&Some(api_url.to_string())),
+ fallback,
+ "hosted inference host must not become the backend API base: {api_url}"
+ );
+ }
+}
+
#[test]
fn backend_url_falls_back_to_env_when_override_is_local_ai() {
let _guard = env_lock();
diff --git a/crates/openhuman-tinyhumans/src/inference/tiers.rs b/crates/openhuman-tinyhumans/src/inference/tiers.rs
index b327e1c89f..b9859aa0e2 100644
--- a/crates/openhuman-tinyhumans/src/inference/tiers.rs
+++ b/crates/openhuman-tinyhumans/src/inference/tiers.rs
@@ -145,7 +145,11 @@ pub(crate) fn normalize_config(config: &mut Config) -> bool {
for route in &mut config.model_routes {
changed |= rewrite(&mut route.model);
}
- if config.cloud_providers.is_empty() {
+ if config.cloud_providers.is_empty()
+ && openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_identity(
+ "openhuman",
+ )
+ {
{
let preset = crate::hosted_config::openhuman_preset();
let id = openhuman_embed::__host::config::schema::cloud_providers::generate_provider_id(