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 context handling for managed providers
Steven Enamakel634fc20c7cae
diff --git a/crates/openhuman-core/src/attachments/provider.rs b/crates/openhuman-core/src/attachments/provider.rsindex d7363a101f..e83cebe4a3 100644--- a/crates/openhuman-core/src/attachments/provider.rs+++ b/crates/openhuman-core/src/attachments/provider.rs@@ -35,11 +35,14 @@ pub(crate) fn wrap(.unwrap_or_default();if provider == "openhuman" || provider == "managed" {let resolved_context = ctx.resolved();- profile.modalities.image_in = crate::inference::registry::provider_model_supports_vision_for(- resolved_context.as_deref().map(crate::core::runtime::CoreContext::extensions),- crate::inference::provider::factory::PROVIDER_OPENHUMAN,- model,- );+ profile.modalities.image_in =+ crate::inference::registry::provider_model_supports_vision_for(+ resolved_context+ .as_deref()+ .map(crate::core::runtime::CoreContext::extensions),+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,+ model,+ );}let route = if matches!(provider, "openhuman" | "managed") {"openhuman".to_string()diff --git a/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs b/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rsindex 624bad52b8..a6a6b8f127 100644--- a/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs+++ b/crates/openhuman-core/src/channels/tests/runtime_tool_calls.rs@@ -101,12 +101,12 @@ async fn process_channel_message_handles_models_command_without_llm_call() {config.cloud_providers.push(crate::config::schema::CloudProviderCreds {- id: "p_managed_models_test".to_string(),- slug: "openhuman".to_string(),- label: "Managed Backend".to_string(),- endpoint: "https://api.openhuman.ai/v1".to_string(),- auth_style: crate::config::schema::AuthStyle::OpenhumanJwt,- default_model: Some("default-model".to_string()),+ id: "p_managed_models_test".to_string(),+ slug: "openhuman".to_string(),+ label: "Managed Backend".to_string(),+ endpoint: "https://api.openhuman.ai/v1".to_string(),+ auth_style: crate::config::schema::AuthStyle::OpenhumanJwt,+ default_model: Some("default-model".to_string()),});let runtime_ctx = Arc::new(ChannelRuntimeContext {relay_thread: None,diff --git a/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs b/crates/openhuman-core/src/inference/provider/factory/managed_backend.rsindex 79f3637c3f..804f6abdad 100644--- a/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs+++ b/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs@@ -36,7 +36,17 @@ pub(super) fn managed_chat_model(thread_id: Option<&str>,egress: &EgressLedger,) -> anyhow::Result<ManagedChatModel> {- managed_chat_model_for(None, role, config, model_override, default_model, native_tool_calling, thread_id, egress)+ let extensions = crate::core::runtime::CoreContext::current_extensions();+ managed_chat_model_for(+ extensions.as_ref(),+ role,+ config,+ model_override,+ default_model,+ native_tool_calling,+ thread_id,+ egress,+ )}pub(super) fn managed_chat_model_for(@@ -50,7 +60,8 @@ pub(super) fn managed_chat_model_for(egress: &EgressLedger,) -> anyhow::Result<ManagedChatModel> {enforce_local_only_inference(role, PROVIDER_OPENHUMAN)?;- let Some(entry) = crate::inference::registry::chat_model_for(extensions, PROVIDER_OPENHUMAN) else {+ let Some(entry) = crate::inference::registry::chat_model_for(extensions, PROVIDER_OPENHUMAN)+ else {log::debug!("[providers][chat-factory] role={role} managed provider is not registered");return Err(managed_unavailable_error());};diff --git a/crates/openhuman-core/src/inference/turn_models.rs b/crates/openhuman-core/src/inference/turn_models.rsindex f1995f63ba..6ef466ef16 100644--- a/crates/openhuman-core/src/inference/turn_models.rs+++ b/crates/openhuman-core/src/inference/turn_models.rs@@ -214,15 +214,16 @@ fn build_turn_models_crate(if tier == model {continue;}- let tier_role = crate::inference::registry::provider_model_role_for(+ let registered_role = crate::inference::registry::provider_model_role_for(context_extensions,factory::PROVIDER_OPENHUMAN,tier,- )- .unwrap_or_else(|| crate::inference::provider_model::role_for_provider_model(- factory::PROVIDER_OPENHUMAN,- tier,- ));+ );+ let tier_role = registered_role.as_deref().unwrap_or_else(|| {+ tier.strip_prefix("hint:")+ .filter(|role| crate::config::WORKLOAD_ROLES.contains(role))+ .unwrap_or("chat")+ });if let Some(custom) = ctx.host_overrides().and_then(|local| {local.role_modelsdiff --git a/crates/openhuman-core/src/inference/turn_models_tests.rs b/crates/openhuman-core/src/inference/turn_models_tests.rsindex 1b38f58167..6bc73322b8 100644--- a/crates/openhuman-core/src/inference/turn_models_tests.rs+++ b/crates/openhuman-core/src/inference/turn_models_tests.rs@@ -23,7 +23,14 @@ fn scoped_model_entry(default_model: Arc::new(move || Some(name.to_string())),role_for_model: Arc::new(move |model| {if model == "fixture-role" {- Some(if supports_vision { "reasoning" } else { "coding" }.to_string())+ Some(+ if supports_vision {+ "reasoning"+ } else {+ "coding"+ }+ .to_string(),+ )} else {model.strip_prefix("hint:").map(str::to_string)}diff --git a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rsindex 5f40bb6c73..6147d092bf 100644--- a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs+++ b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs@@ -170,7 +170,9 @@ fn hosted_cost_defaults_include_the_registered_managed_model_price() {let _registry = crate::registry_test_lock();crate::register::register_all(&crate::install::InstallOptions::default());- let prices = openhuman_embed::__host::config::Config::default().cost.prices;+ let prices = openhuman_embed::__host::config::Config::default()+ .cost+ .prices;let expected = super::super::tiers::default_pricing().expect("hosted default pricing");assert_eq!(expected.0, MODEL_MANAGED_DEFAULT);let actual = prices