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 Enamakel732a7959e32c
diff --git a/crates/openhuman-core/src/config/schema/cloud_providers.rs b/crates/openhuman-core/src/config/schema/cloud_providers.rs
index 7ae2b95b45..fdce83d2b2 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers.rs
@@ -139,7 +139,14 @@ fn hosted_has_slug(slug: &str) -> bool {
.any(|(_, preset)| preset.slug == slug)
}
-fn provider_presets(hosted: &[BuiltinCloudProvider]) -> BuiltinPresets {
+/// 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 {
+ let hosted = HOSTED_PRESETS
+ .entries_context_first()
+ .into_iter()
+ .map(|(_, preset)| preset)
+ .collect::<Vec<_>>();
BuiltinPresets::new(hosted.iter().map(|preset| UpstreamBuiltinCloudProvider {
slug: preset.slug,
label: preset.label,
@@ -170,41 +177,6 @@ pub fn builtin_cloud_provider(type_str: &str) -> Option<BuiltinCloudProvider> {
.map(BuiltinCloudProvider::from)
}
-/// Whether `slug` matches a built-in cloud provider preset.
-///
-/// The chat factory uses this to decide capability defaults (e.g. whether the
-/// provider exposes the OpenAI Responses API) only for providers we ship and
-/// therefore know the API surface of. Custom / user-defined slugs are treated
-/// as unknown and keep the permissive defaults.
-pub fn is_builtin_cloud_slug(slug: &str) -> bool {
- builtin_cloud_provider(slug).is_some()
-}
-
-/// Whether a built-in cloud provider exposes the OpenAI **Responses API**
-/// (`/v1/responses`).
-///
-/// Only OpenAI's first-party endpoint serves `/responses`; every other built-in
-/// preset (DeepSeek, Groq, Mistral, Fireworks, …) is chat-completions-only.
-/// Enabling the chat-completions-404 → `/responses` fallback for those
-/// guarantees a second 404 against an endpoint that does not exist, which floods
-/// Sentry with an empty-body `"<provider> Responses API error:"` event
-/// (TAURI-RUST-5EN — same class as the local-provider TAURI-RUST-59Y fix). The
-/// factory consults this to build chat-completions-only built-ins with
-/// `new_no_responses_fallback`.
-///
-/// Custom / unknown slugs are intentionally NOT covered here (see
-/// [`is_builtin_cloud_slug`]): a user-defined OpenAI-compatible endpoint may be
-/// a genuine OpenAI proxy that does support `/responses`, so the factory keeps
-/// the fallback for those.
-pub fn builtin_cloud_supports_responses_api(slug: &str) -> bool {
- let hosted = HOSTED_PRESETS
- .entries_context_first()
- .into_iter()
- .map(|(_, preset)| preset)
- .collect::<Vec<_>>();
- provider_presets(&hosted).builtin_cloud_supports_responses_api(slug)
-}
-
/// Whether `host` is the authority host of any built-in cloud **inference**
/// provider (e.g. `openrouter.ai`, `api.openai.com`, `api.groq.com`).
///
@@ -223,15 +195,6 @@ pub fn builtin_cloud_supports_responses_api(slug: &str) -> bool {
/// The backend-URL resolver uses this to treat such hosts as non-backend and
/// fall back to the default backend chain — the cloud analogue of the local-AI
/// guard that fixed the Ollama case (OPENHUMAN-TAURI-51/-80/-7Z).
-pub fn host_is_builtin_cloud_provider(host: &str) -> bool {
- let hosted = HOSTED_PRESETS
- .entries_context_first()
- .into_iter()
- .map(|(_, preset)| preset)
- .collect::<Vec<_>>();
- provider_presets(&hosted).host_is_builtin_cloud_provider(host)
-}
-
/// Whether an endpoint **host** is a known cloud host that does NOT serve the
/// OpenAI Responses API (`/v1/responses`) — i.e. it is chat-completions-only,
/// regardless of which user slug points at it.
@@ -244,15 +207,6 @@ pub fn host_is_builtin_cloud_provider(host: &str) -> bool {
/// `integrate.api.nvidia.com` must never attempt `/responses` (TAURI-RUST-5A1),
/// while a genuinely unknown proxy host keeps the permissive fallback so a real
/// OpenAI proxy still gets `/responses`.
-pub fn endpoint_host_is_chat_completions_only(endpoint: &str) -> bool {
- let hosted = HOSTED_PRESETS
- .entries_context_first()
- .into_iter()
- .map(|(_, preset)| preset)
- .collect::<Vec<_>>();
- provider_presets(&hosted).endpoint_host_is_chat_completions_only(endpoint)
-}
-
/// Authentication header style for a cloud provider.
///
/// Wire format is lowercase (e.g. `"bearer"`). Determines which HTTP headers
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 a23cb40881..58bdd8abe9 100644
--- a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
+++ b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs
@@ -1,9 +1,7 @@
//! Tests for the surrounding module.
use super::{
- builtin_cloud_providers, builtin_cloud_supports_responses_api,
- endpoint_host_is_chat_completions_only, host_is_builtin_cloud_provider, is_builtin_cloud_slug,
- is_slug_reserved, AuthStyle,
+ builtin_cloud_providers, builtin_presets, is_slug_reserved, AuthStyle,
};
use tinyinference_providers::builtin::endpoint_host;
@@ -106,11 +104,11 @@ fn builtin_cloud_provider_slugs_are_unique() {
#[test]
fn is_builtin_cloud_slug_matches_presets_only() {
for slug in ["openai", "deepseek", "groq", "mistral"] {
- assert!(is_builtin_cloud_slug(slug), "{slug} is a built-in preset");
+ assert!(builtin_presets().is_builtin_cloud_slug(slug), "{slug} is a built-in preset");
}
for slug in ["my-proxy", "custom-openai", "totally-unknown", ""] {
assert!(
- !is_builtin_cloud_slug(slug),
+ !builtin_presets().is_builtin_cloud_slug(slug),
"{slug:?} is not a built-in preset"
);
}
@@ -118,14 +116,14 @@ fn is_builtin_cloud_slug_matches_presets_only() {
#[test]
fn builtin_responses_capabilities_follow_provider_catalog() {
- assert!(builtin_cloud_supports_responses_api("openai"));
+ assert!(builtin_presets().builtin_cloud_supports_responses_api("openai"));
// The merged provider catalog documents these OpenAI-compatible gateways
// as supporting /responses too. Preserve that upstream protocol contract.
- assert!(builtin_cloud_supports_responses_api("openrouter"));
- assert!(builtin_cloud_supports_responses_api("xai"));
+ assert!(builtin_presets().builtin_cloud_supports_responses_api("openrouter"));
+ assert!(builtin_presets().builtin_cloud_supports_responses_api("xai"));
for slug in ["deepseek", "groq", "mistral", "fireworks", "together"] {
assert!(
- !builtin_cloud_supports_responses_api(slug),
+ !builtin_presets().builtin_cloud_supports_responses_api(slug),
"{slug} is chat-completions-only and must not advertise the Responses API"
);
}
@@ -184,7 +182,7 @@ fn responses_api_capability_is_coupled_to_the_preset_list() {
for provider in builtin_cloud_providers().iter() {
let expected = provider.slug == "openai";
assert_eq!(
- builtin_cloud_supports_responses_api(provider.slug),
+ builtin_presets().builtin_cloud_supports_responses_api(provider.slug),
expected,
"built-in {} Responses-API capability drifted from the openai-only invariant",
provider.slug
@@ -230,7 +228,7 @@ fn host_is_builtin_cloud_provider_recognises_inference_hosts() {
"API.OPENAI.COM", // case-insensitive
] {
assert!(
- host_is_builtin_cloud_provider(host),
+ builtin_presets().host_is_builtin_cloud_provider(host),
"{host} is a built-in cloud inference host"
);
}
@@ -241,7 +239,7 @@ fn host_is_builtin_cloud_provider_recognises_inference_hosts() {
"",
] {
assert!(
- !host_is_builtin_cloud_provider(host),
+ !builtin_presets().host_is_builtin_cloud_provider(host),
"{host:?} is not a built-in cloud inference host"
);
}
@@ -249,7 +247,7 @@ fn host_is_builtin_cloud_provider_recognises_inference_hosts() {
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),
+ builtin_presets().host_is_builtin_cloud_provider(&host),
"{} ({host}) must be recognised",
provider.slug
);
@@ -262,7 +260,7 @@ fn host_is_builtin_cloud_provider_recognises_inference_hosts() {
/// the slug is not builtin.
#[test]
fn nvidia_host_is_chat_completions_only_regardless_of_slug() {
- assert!(endpoint_host_is_chat_completions_only(
+ assert!(builtin_presets().endpoint_host_is_chat_completions_only(
"https://integrate.api.nvidia.com/v1"
));
// Other chat-only built-in hosts too.
@@ -272,7 +270,7 @@ fn nvidia_host_is_chat_completions_only_regardless_of_slug() {
"https://api.mistral.ai/v1",
] {
assert!(
- endpoint_host_is_chat_completions_only(endpoint),
+ builtin_presets().endpoint_host_is_chat_completions_only(endpoint),
"{endpoint} is a chat-completions-only built-in host"
);
}
@@ -282,7 +280,7 @@ fn nvidia_host_is_chat_completions_only_regardless_of_slug() {
fn openai_host_and_unknown_proxies_keep_the_responses_fallback() {
// OpenAI's first-party host serves /responses — must NOT be gated off,
// even via a custom proxy slug pointed at it.
- assert!(!endpoint_host_is_chat_completions_only(
+ assert!(!builtin_presets().endpoint_host_is_chat_completions_only(
"https://api.openai.com/v1"
));
// Genuinely unknown proxy hosts keep the permissive default (they may be
@@ -293,7 +291,7 @@ fn openai_host_and_unknown_proxies_keep_the_responses_fallback() {
"",
] {
assert!(
- !endpoint_host_is_chat_completions_only(endpoint),
+ !builtin_presets().endpoint_host_is_chat_completions_only(endpoint),
"{endpoint:?} is an unknown host and must keep the fallback"
);
}
@@ -311,8 +309,8 @@ fn host_gate_agrees_with_slug_capability_for_every_builtin() {
if provider.auth_style != AuthStyle::Bearer {
continue;
}
- let host_chat_only = endpoint_host_is_chat_completions_only(provider.endpoint);
- let slug_supports = builtin_cloud_supports_responses_api(provider.slug);
+ let host_chat_only = builtin_presets().endpoint_host_is_chat_completions_only(provider.endpoint);
+ let slug_supports = builtin_presets().builtin_cloud_supports_responses_api(provider.slug);
assert_eq!(
host_chat_only, !slug_supports,
"host gate for built-in {} disagrees with its slug capability",
diff --git a/crates/openhuman-core/src/inference/provider/factory_route_resolution_tests.rs b/crates/openhuman-core/src/inference/provider/factory_route_resolution_tests.rs
index f32c941684..a115e4cb49 100644
--- a/crates/openhuman-core/src/inference/provider/factory_route_resolution_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_route_resolution_tests.rs
@@ -555,6 +555,17 @@ fn local_only_defers_reresolving_sentinels() {
assert_eq!(local_only_violation(PrivacyMode::LocalOnly, "cloud"), None);
}
+#[test]
+fn local_only_does_not_treat_unresolved_route_sentinels_as_local() {
+ use crate::config::PrivacyMode;
+ for route in ["cloud:gpt-4o", ":gpt-4o"] {
+ assert!(
+ local_only_violation(PrivacyMode::LocalOnly, route).is_some(),
+ "an unresolved route must remain blocked under LocalOnly: {route}"
+ );
+ }
+}
+
#[test]
fn standard_mode_permits_external() {
use crate::config::PrivacyMode;
diff --git a/crates/openhuman-tinyhumans/src/backend/url.rs b/crates/openhuman-tinyhumans/src/backend/url.rs
index 59e09c0893..8c4c38f26c 100644
--- a/crates/openhuman-tinyhumans/src/backend/url.rs
+++ b/crates/openhuman-tinyhumans/src/backend/url.rs
@@ -162,16 +162,7 @@ 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 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 presets = crate::hosted_config::provider_presets();
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/hosted_config.rs b/crates/openhuman-tinyhumans/src/hosted_config.rs
index f921552a2b..744a456549 100644
--- a/crates/openhuman-tinyhumans/src/hosted_config.rs
+++ b/crates/openhuman-tinyhumans/src/hosted_config.rs
@@ -21,6 +21,20 @@ pub(crate) fn openhuman_preset() -> BuiltinCloudProvider {
}
}
+pub(crate) fn provider_presets() -> tinyinference_providers::builtin::BuiltinPresets {
+ let preset = openhuman_preset();
+ tinyinference_providers::builtin::BuiltinPresets::new([
+ tinyinference_providers::builtin::BuiltinCloudProvider {
+ slug: preset.slug,
+ label: preset.label,
+ endpoint: preset.endpoint,
+ // This catalog is used for host and protocol classification only;
+ // the session JWT remains governed by TinyHumans' auth policy.
+ auth_style: tinyinference_providers::builtin::BuiltinAuthStyle::Bearer,
+ },
+ ])
+}
+
#[cfg(test)]
#[path = "hosted_config_tests.rs"]
mod tests;
diff --git a/crates/openhuman-tinyhumans/src/hosted_config_tests.rs b/crates/openhuman-tinyhumans/src/hosted_config_tests.rs
index 79e803ca02..d82124b580 100644
--- a/crates/openhuman-tinyhumans/src/hosted_config_tests.rs
+++ b/crates/openhuman-tinyhumans/src/hosted_config_tests.rs
@@ -12,9 +12,7 @@ fn hosted_openhuman_preset_and_legacy_auth_policy_are_registered_before_config_l
"openhuman"
)
);
- assert!(openhuman_embed::__host::config::schema::cloud_providers::endpoint_host_is_chat_completions_only(
- preset.endpoint
- ));
+ assert!(super::provider_presets().endpoint_host_is_chat_completions_only(preset.endpoint));
assert!(
!openhuman_embed::__host::config::schema::cloud_providers::is_hosted_auth_style(