Skip to content

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

feat(profiles): apply operator provider bindings to sessions and search

Steven Enamakel7fa454a60a9b
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 2ea92c58f7..884befce4d 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -154,6 +154,12 @@ impl OpenHumanSessionHost {
host: Option<&super::HostTools>,
session_id: Option<&str>,
) -> Result<Self> {
+ let profile_config = config.profile_providers.as_ref().map(|binding| {
+ let mut direct = config.clone();
+ binding.apply_chat(&mut direct);
+ direct
+ });
+ let config = profile_config.as_ref().unwrap_or(config);
let workspace_descriptor = derive_turn_workspace_descriptor();
let runtime: Arc<dyn host_runtime::RuntimeAdapter> = Arc::from(
@@ -296,6 +302,10 @@ impl OpenHumanSessionHost {
model_name = pinned_model.to_string();
}
+ if let Some(model) = config.profile_providers.as_ref().and_then(|binding| binding.chat_model()) {
+ model_name = model.to_owned();
+ }
+
// Resolve the user-configured vision flag for the (now-final) model while
// the full `Config` / `model_registry` is in scope — the turn engine only
// sees `MultimodalConfig`. Stored on the session and surfaced to the image
diff --git a/crates/openhuman-core/src/config/ops/loader/load.rs b/crates/openhuman-core/src/config/ops/loader/load.rs
index b406739f93..b0d7ecdf6d 100644
--- a/crates/openhuman-core/src/config/ops/loader/load.rs
+++ b/crates/openhuman-core/src/config/ops/loader/load.rs
@@ -185,6 +185,7 @@ async fn normalize_loaded_config(config: &mut Config) {
// `chat_onboarding_completed` field is retained only for backward-compatible
// deserialization.
+ if let Some(binding) = config.profile_providers.clone() { binding.apply_chat(config); }
seed_and_enrich_model_registry(config);
}
diff --git a/crates/openhuman-core/src/modules/search/mod.rs b/crates/openhuman-core/src/modules/search/mod.rs
index ddc90b995d..1ce6a1e0fe 100644
--- a/crates/openhuman-core/src/modules/search/mod.rs
+++ b/crates/openhuman-core/src/modules/search/mod.rs
@@ -50,6 +50,7 @@ fn direct_settings(config: &Config, provider: &str) -> ProviderConfig {
settings.default_language = Some(config.searxng.default_language.clone());
}
other => {
+ settings.base_url = search.credentials(other).and_then(|c| c.base_url.clone());
settings.credential = search
.credentials(other)
.and_then(|c| c.key())
@@ -76,10 +77,13 @@ fn provider_config(config: &Config, provider: &ResolvedProvider) -> ProviderConf
/// The complete private configuration for TinySearch.
pub fn module_config(config: &Config) -> ModuleSearchConfig {
- let credential =
- crate::security::credentials::session_support::resolve_backend_credential(config).ok();
+ let private = config.profile_providers.as_ref().map(|binding| binding.effective_search(config));
+ let config = private.as_ref().unwrap_or(config);
+ let direct_profile = config.profile_providers.is_some();
+ let credential = if direct_profile { None } else {
+ crate::security::credentials::session_support::resolve_backend_credential(config).ok() };
let resolved = providers::resolve_with(config, credential.is_some());
- let backend = BackendConfig {
+ let backend = if direct_profile { BackendConfig::default() } else { BackendConfig {
base_url: crate::backend::base_url(&config.api_url).ok(),
auth_mode: if credential.as_ref().is_some_and(|c| c.is_api_key()) {
BackendAuthMode::ApiKey
@@ -88,7 +92,7 @@ pub fn module_config(config: &Config) -> ModuleSearchConfig {
},
credential: credential.map(|c| c.into_secret()),
sdk_name: crate::backend::product_identity(),
- };
+ } };
let mut module_providers: BTreeMap<String, ProviderConfig> = resolved
.iter()
@@ -97,7 +101,7 @@ pub fn module_config(config: &Config) -> ModuleSearchConfig {
.collect();
// Deep research runs on the direct Gemini API and needs the user's key,
// even when grounded Gemini answers go through the managed route.
- if module_providers.contains_key("gemini")
+ if !direct_profile && module_providers.contains_key("gemini")
&& !module_providers.contains_key("gemini_deep_research")
{
let mut deep = direct_settings(config, "gemini_deep_research");
@@ -147,7 +151,9 @@ pub fn configured_tool_specs(config: &Config) -> Vec<tinysearch_bus::ToolSpec> {
}
let available =
tinysearch_bus::configured_provider_tools(&module, &tinysearch_bus::provider_tool_specs());
- tinysearch_bus::select_tools(&available, &module.presentation).tools
+ let mut specs = tinysearch_bus::select_tools(&available, &module.presentation).tools;
+ if let Some(binding) = &config.profile_providers { binding.present(&mut specs); }
+ specs
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rs
index 6f006126f2..9d5830db9f 100644
--- a/crates/openhuman-core/src/profiles/host.rs
+++ b/crates/openhuman-core/src/profiles/host.rs
@@ -141,6 +141,7 @@ impl ProfileHost {
operator: Arc<CoreContext>,
backend: Option<Arc<dyn StorageBackend>>,
) -> Result<Self, String> {
+ super::provider_settings::ProfileProviderSettings::from_saas(&saas).map_err(|error| error.to_string())?;
let node = saas.resolve_node_id(None).to_owned();
let leases = profile_lease::store_for(
&saas.root,
@@ -300,6 +301,9 @@ impl ProfileHost {
return Err(OpenError::Storage(error));
}
let mut config = layout::profile_config(&layout, id);
+ let providers = super::provider_settings::ProfileProviderSettings::from_saas(&self.saas)
+ .map_err(|error| OpenError::Storage(error.to_string()))?;
+ providers.bind(&mut config);
if let Some(capabilities) = &self.capabilities {
capabilities.configure(&mut config);
}
diff --git a/crates/openhuman-core/src/profiles/provider_settings.rs b/crates/openhuman-core/src/profiles/provider_settings.rs
index 3acd50dc1b..aa5460225e 100644
--- a/crates/openhuman-core/src/profiles/provider_settings.rs
+++ b/crates/openhuman-core/src/profiles/provider_settings.rs
@@ -8,6 +8,8 @@
use std::collections::{BTreeMap, HashSet};
use std::sync::Arc;
use tinysearch_bus::Role;
+/// Search capability vocabulary for operator presentation settings.
+pub use tinysearch_bus::Role as SearchRole;
use crate::config::{Config, SearchConfig, SearchPresentation, SearchProviderSettings, SearchRoute};
use crate::core::runtime::direct_profile_provider::{DirectProfileProvider, validate_endpoint};
use crate::core::runtime::SaasConfig;
diff --git a/crates/openhuman-embed/src/config.rs b/crates/openhuman-embed/src/config.rs
index 6990e17108..fcfca0b748 100644
--- a/crates/openhuman-embed/src/config.rs
+++ b/crates/openhuman-embed/src/config.rs
@@ -108,3 +108,8 @@ pub fn read_active_user_id(root: &Path) -> Option<String> {
#[cfg(test)]
#[path = "config_tests.rs"]
mod tests;
+
+/// Operator search policy and direct-route credential vocabulary.
+pub use openhuman_core::config::{SearchConfig, SearchEngineCredentials, SearchPresentation, SearchProviderSettings, SearchRoute};
+/// The three native search capabilities whose names an operator can present.
+pub use openhuman_core::profiles::provider_settings::SearchRole;
diff --git a/crates/openhuman-embed/src/profiles.rs b/crates/openhuman-embed/src/profiles.rs
index b55b66d2c8..205e204321 100644
--- a/crates/openhuman-embed/src/profiles.rs
+++ b/crates/openhuman-embed/src/profiles.rs
@@ -67,6 +67,8 @@ pub use handle::{ChatReply, ProfileEvents, ProfileHandle, RelayAccepted};
pub use openhuman_core::channels::providers::relay::RelayInboundParams as RelayMessage;
pub use openhuman_core::core::runtime::saas::SaasSandboxConfig;
pub use openhuman_core::core::runtime::SaasConfig;
+/// Validated operator-owned direct inference settings.
+pub use openhuman_core::core::runtime::direct_profile_provider::DirectProfileProvider;
pub use openhuman_core::profiles::{OpenError, ProfileId, ProfileIdMode, ProfileSummary};
pub use openhuman_core::storage::lease::LeaseRecord;
pub use openhuman_core::threads::{ConversationMessageRecord, ConversationThreadSummary};