The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(inference): update model role and raw model logic
Steven Enamakel19792f4f3228
diff --git a/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rs b/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rsindex 331b827155..2f288e7f99 100644--- a/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rs+++ b/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rs@@ -11,7 +11,24 @@ use super::*;async fn cached_probe_inference_readiness_caches_a_negative_result() {use std::sync::atomic::{AtomicUsize, Ordering};- use crate::inference::registry::{register_chat_model, unregister_chat_model, ChatModelEntry};+ use crate::inference::registry::{+ register_chat_model, unregister_chat_model, BackendErrorClassification, ChatModelEntry,+ ProviderModelHooks,+ };+ use async_trait::async_trait;+ use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};++ struct ProbeTestModel;+ #[async_trait]+ impl ChatModel<()> for ProbeTestModel {+ async fn invoke(+ &self,+ _state: &(),+ _request: ModelRequest,+ ) -> tinyinference_llm::Result<ModelResponse> {+ Ok(ModelResponse::assistant("probe test"))+ }+ }let _guard = crate::inference::inference_test_guard_async().await;let tmp = TempDir::new().unwrap();@@ -27,15 +44,36 @@ async fn cached_probe_inference_readiness_caches_a_negative_result() {counter.fetch_add(1, Ordering::SeqCst);Box::pin(async { Err("API key not configured for provider".to_string()) })});- let base = crate::inference::registry_test_support::default_managed_entry(- crate::inference::provider::factory::PROVIDER_OPENHUMAN,- )- .expect("test default managed provider");register_chat_model(crate::inference::provider::factory::PROVIDER_OPENHUMAN,ChatModelEntry {+ build: Arc::new(|request| {+ let model = request+ .model_override+ .or(request.default_model)+ .unwrap_or("fixture-model")+ .to_string();+ Ok((Arc::new(ProbeTestModel), model))+ }),probe: Some(probe),- ..base+ models: Some(ProviderModelHooks {+ default_model: Arc::new(|| Some("fixture-model".to_string())),+ role_for_model: Arc::new(|_| None),+ is_alias: Arc::new(|_| false),+ is_raw_model: Arc::new(|model| !model.starts_with("hint:")),+ supports_vision: Arc::new(|_| false),+ resolve_model: Arc::new(|_, config, model| {+ model+ .map(str::trim)+ .filter(|model| !model.is_empty() && !model.starts_with("hint:"))+ .map(str::to_string)+ .or_else(|| config.default_model.clone())+ .or_else(|| Some("fixture-model".to_string()))+ }),+ context_window: Arc::new(|_| None),+ default_pricing: Arc::new(|| None),+ without_reasoning: Arc::new(|request| request),+ }),},);struct Unregister;diff --git a/crates/openhuman-core/src/inference/provider_model_tests.rs b/crates/openhuman-core/src/inference/provider_model_tests.rsindex 084d825573..77758698d7 100644--- a/crates/openhuman-core/src/inference/provider_model_tests.rs+++ b/crates/openhuman-core/src/inference/provider_model_tests.rs@@ -18,8 +18,8 @@ fn abstract_hint_markers_do_not_become_raw_model_ids() {assert!(is_abstract_model("missing-provider", "hint:unknown"));assert!(!is_raw_model("missing-provider", "hint:unknown"));assert!(is_raw_model("missing-provider", "vendor/model-id"));- assert!(!is_raw_model("missing-provider", "chat"));- assert!(!is_raw_model("missing-provider", "coding"));+ assert!(is_raw_model("missing-provider", "chat"));+ assert!(is_raw_model("missing-provider", "coding"));assert_eq!(role_for_provider_model("missing-provider", "hint:coding"),"coding"diff --git a/crates/openhuman-core/src/inference/registry.rs b/crates/openhuman-core/src/inference/registry.rsindex 7cdda7a9f4..b49c20b832 100644--- a/crates/openhuman-core/src/inference/registry.rs+++ b/crates/openhuman-core/src/inference/registry.rs@@ -233,7 +233,6 @@ pub fn provider_model_is_raw(provider_id: &str, model: &str) -> bool {let model = model.trim();!model.is_empty()&& !model.starts_with("hint:")- && !crate::config::WORKLOAD_ROLES.contains(&model)&& provider_model_hooks(provider_id).map_or(true, |hooks| (hooks.is_raw_model)(model))}diff --git a/crates/openhuman-tinyhumans/src/inference/tiers.rs b/crates/openhuman-tinyhumans/src/inference/tiers.rsindex ec4a80f6d5..f42c60a9e2 100644--- a/crates/openhuman-tinyhumans/src/inference/tiers.rs+++ b/crates/openhuman-tinyhumans/src/inference/tiers.rs@@ -42,18 +42,11 @@ fn hint_role(model: &str) -> Option<&'static str> {pub(crate) fn role_for_model(model: &str) -> Option<String> {hint_role(model).or_else(|| legacy_tier_role(model))- .or_else(|| {- openhuman_embed::__host::config::WORKLOAD_ROLES- .contains(&model.trim())- .then(|| model.trim())- }).map(str::to_string)}pub(crate) fn is_alias(model: &str) -> bool {- hint_role(model).is_some()- || legacy_tier_role(model).is_some()- || openhuman_embed::__host::config::WORKLOAD_ROLES.contains(&model.trim())+ hint_role(model).is_some() || legacy_tier_role(model).is_some()}pub(crate) fn is_raw_model(model: &str) -> bool {diff --git a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rsindex f6eb6748a3..119208d32e 100644--- a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs+++ b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs@@ -112,6 +112,11 @@ fn managed_tier_vocabulary_maps_aliases_and_leaves_concrete_ids_raw() {assert!(is_alias(model));}assert!(is_raw_model("vendor/concrete-model"));+ assert!(is_raw_model("chat"));+ assert_eq!(+ resolve_model("chat", &Config::default(), Some("coding")).as_deref(),+ Some("coding")+ );assert!(!is_raw_model("hint:unknown"));}