Skip to content

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

refactor(inference): use unified abstract model check

Steven Enamakelec7e3c504cad
diff --git a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
index b53f7f4600..2b7482ed2b 100644
--- a/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/cloud_slug.rs
@@ -86,12 +86,12 @@ pub(super) fn resolve_cloud_slug<'a>(
);
}
- if !hosted && is_abstract_tier_model(&effective_model) {
+ if !hosted && crate::inference::provider_model::is_abstract_model(PROVIDER_OPENHUMAN, &effective_model) {
if let Some(default_model) = entry
.default_model
.as_deref()
.map(str::trim)
- .filter(|m| !m.is_empty() && !is_abstract_tier_model(m))
+ .filter(|m| !m.is_empty() && !crate::inference::provider_model::is_abstract_model(PROVIDER_OPENHUMAN, m))
{
log::info!(
"[providers][chat-factory] role={} slug={} remapping abstract model {} -> {}",
diff --git a/crates/openhuman-core/src/inference/provider_model.rs b/crates/openhuman-core/src/inference/provider_model.rs
index a3d895cc1f..bc139c53a9 100644
--- a/crates/openhuman-core/src/inference/provider_model.rs
+++ b/crates/openhuman-core/src/inference/provider_model.rs
@@ -27,6 +27,13 @@ pub fn is_raw_model(provider_id: &str, model: &str) -> bool {
crate::inference::registry::provider_model_is_raw(provider_id, model)
}
+/// `hint:*` is an abstract routing marker even if no installed provider
+/// recognizes the suffix; never pass it to a concrete BYOK endpoint.
+pub fn is_abstract_model(provider_id: &str, model: &str) -> bool {
+ model.trim().starts_with("hint:")
+ || crate::inference::registry::provider_model_is_alias(provider_id, model)
+}
+
/// Resolve a model hint according to the configured provider route and the
/// route's registered provider model policy.
pub fn resolve_provider_model_hint(provider_id: &str, hint: &str, config: &Config) -> String {
diff --git a/crates/openhuman-tinyhumans/src/hosted_config.rs b/crates/openhuman-tinyhumans/src/hosted_config.rs
index 22b3972aa0..31518b6d70 100644
--- a/crates/openhuman-tinyhumans/src/hosted_config.rs
+++ b/crates/openhuman-tinyhumans/src/hosted_config.rs
@@ -18,3 +18,7 @@ pub(crate) fn register() {
slug == "openhuman" || style == AuthStyle::OpenhumanJwt
}));
}
+
+#[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
new file mode 100644
index 0000000000..a0a1f31580
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/hosted_config_tests.rs
@@ -0,0 +1,26 @@
+use super::*;
+
+#[test]
+fn hosted_openhuman_preset_and_legacy_auth_policy_are_registered_before_config_load() {
+ register();
+
+ let preset = openhuman_embed::__host::config::schema::cloud_providers::builtin_cloud_provider(
+ "openhuman",
+ )
+ .expect("TinyHumans registers the hosted preset");
+ assert_eq!(preset.endpoint, "https://api.openhuman.ai/v1");
+ assert_eq!(preset.auth_style, AuthStyle::OpenhumanJwt);
+
+ assert!(openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_provider(
+ "openhuman",
+ AuthStyle::Bearer,
+ ));
+ assert!(openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_provider(
+ "legacy-custom-slug",
+ AuthStyle::OpenhumanJwt,
+ ));
+ assert!(!openhuman_embed::__host::config::schema::cloud_providers::is_hosted_cloud_provider(
+ "ordinary-provider",
+ AuthStyle::Bearer,
+ ));
+}