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
test(core): add context scoping tests for providers and models
Steven Enamakela905670071cf
diff --git a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rsindex adf54235c8..96dc88c8ca 100644--- a/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs+++ b/crates/openhuman-core/src/config/schema/cloud_providers_tests.rs@@ -126,6 +126,41 @@ fn only_openai_builtin_exposes_responses_api() {}}+#[test]+fn hosted_presets_and_classification_are_context_scoped() {+ use crate::core::slots::Extensions;++ let extensions = Extensions::new();+ super::register_hosted_cloud_preset_in(+ &extensions,+ "tenant-hosted",+ super::BuiltinCloudProvider {+ slug: "tenant-hosted",+ label: "Tenant Hosted",+ endpoint: "https://tenant.example/v1",+ auth_style: AuthStyle::Bearer,+ },+ );+ super::register_hosted_cloud_provider_policy_in(+ &extensions,+ std::sync::Arc::new(|slug, _| slug == "tenant-hosted"),+ );+ let context = crate::core::runtime::CoreContext::for_test_with_extensions(+ crate::core::runtime::DomainSet::full(),+ None,+ extensions,+ );++ assert!(super::builtin_cloud_provider("tenant-hosted").is_none());+ crate::core::runtime::CoreContext::sync_scope(context, || {+ assert!(super::builtin_cloud_provider("tenant-hosted").is_some());+ assert!(super::is_hosted_cloud_provider("tenant-hosted", AuthStyle::Bearer));+ assert!(!super::is_hosted_cloud_provider("openai", AuthStyle::Bearer));+ });+ assert!(super::builtin_cloud_provider("tenant-hosted").is_none());+ assert!(!super::is_hosted_cloud_provider("tenant-hosted", AuthStyle::Bearer));+}+/// Drift guard (TAURI-RUST-5EN): couple the capability helper to the/// preset list so adding a new built-in that wrongly claims the Responses/// API — or renaming `openai` — fails CI rather than silently re-enablingdiff --git a/crates/openhuman-core/src/inference/provider_model_tests.rs b/crates/openhuman-core/src/inference/provider_model_tests.rsindex 8052970af5..a1d8a14651 100644--- a/crates/openhuman-core/src/inference/provider_model_tests.rs+++ b/crates/openhuman-core/src/inference/provider_model_tests.rs@@ -21,3 +21,60 @@ fn abstract_hint_markers_do_not_become_raw_model_ids() {assert_eq!(role_for_provider_model("missing-provider", "hint:coding"), "coding");assert_eq!(role_for_provider_model("missing-provider", "hint:unknown"), "chat");}++#[test]+fn registered_model_defaults_and_aliases_are_context_scoped() {+ use crate::core::slots::Extensions;+ use crate::inference::registry::{+ register_chat_model_in, ChatModelEntry, ProviderModelHooks,+ };+ use std::sync::Arc;++ let extensions = Extensions::new();+ register_chat_model_in(+ &extensions,+ "scoped-provider",+ ChatModelEntry {+ build: Arc::new(|_| Err(anyhow::anyhow!("test factory"))),+ probe: None,+ models: Some(ProviderModelHooks {+ default_model: Arc::new(|| Some("scoped/model".to_string())),+ role_for_model: Arc::new(|model| {+ (model == "scoped-alias").then(|| "reasoning".to_string())+ }),+ is_alias: Arc::new(|model| model == "scoped-alias"),+ is_raw_model: Arc::new(|model| model == "scoped/model"),+ supports_vision: Arc::new(|_| false),+ resolve_model: Arc::new(|_, _, _| None),+ context_window: Arc::new(|_| None),+ default_pricing: Arc::new(|| None),+ without_reasoning: Arc::new(|request| request),+ }),+ },+ );+ let context = crate::core::runtime::CoreContext::for_test_with_extensions(+ crate::core::runtime::DomainSet::full(),+ None,+ extensions,+ );++ assert_eq!(+ crate::inference::registry::provider_default_model("scoped-provider"),+ None+ );+ crate::core::runtime::CoreContext::sync_scope(context, || {+ assert_eq!(+ crate::inference::registry::provider_default_model("scoped-provider").as_deref(),+ Some("scoped/model")+ );+ assert_eq!(+ crate::inference::registry::provider_model_role("scoped-provider", "scoped-alias")+ .as_deref(),+ Some("reasoning")+ );+ });+ assert_eq!(+ crate::inference::registry::provider_default_model("scoped-provider"),+ None+ );+}