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(runtime): resolve tenant scope through current_tenant
Steven Enamakel5a4ad637fb3a
diff --git a/crates/openhuman-core/src/cron/completion_owner.rs b/crates/openhuman-core/src/cron/completion_owner.rsindex b4417432aa..e2e3d390d8 100644--- a/crates/openhuman-core/src/cron/completion_owner.rs+++ b/crates/openhuman-core/src/cron/completion_owner.rs@@ -22,8 +22,9 @@ static OWNERS: LazyLock<Mutex<HashMap<String, String>>> = LazyLock::new(Default:/// Notes that `job_id` just completed as the current context's agent, when/// it ran as one. Call just before publishing `CronJobCompleted`.pub fn note(job_id: &str) {- let Some(agent) = crate::core::runtime::CoreContext::current()- .and_then(|context| context.session_agent().map(str::to_string))+ let Some(agent) = crate::core::runtime::current_tenant()+ .ok()+ .and_then(|tenant| tenant.agent)else {return;};diff --git a/crates/openhuman-core/src/flows/bus/trigger.rs b/crates/openhuman-core/src/flows/bus/trigger.rsindex 80bacb58ef..a94a70e771 100644--- a/crates/openhuman-core/src/flows/bus/trigger.rs+++ b/crates/openhuman-core/src/flows/bus/trigger.rs@@ -116,8 +116,9 @@ impl FlowTriggerSubscriber {/// — its provider, access policy and action directory — else the one this/// subscriber was registered with.pub(super) fn config_for_scope(&self) -> Arc<Config> {- let acting = crate::core::runtime::CoreContext::current()- .is_some_and(|context| context.session_agent().is_some());+ // A SaaS profile acts as its own tenant even with no agent inside it.+ let acting = crate::core::runtime::current_tenant()+ .is_ok_and(|tenant| tenant.agent.is_some() || tenant.profile.is_some());match acting.then(crate::core::runtime::CoreContext::current_embedder_config) {Some(Some(config)) => Arc::new(config),_ => Arc::clone(&self.config),diff --git a/crates/openhuman-core/src/integrations/task_sources/periodic.rs b/crates/openhuman-core/src/integrations/task_sources/periodic.rsindex d38cc0e530..718fe25e00 100644--- a/crates/openhuman-core/src/integrations/task_sources/periodic.rs+++ b/crates/openhuman-core/src/integrations/task_sources/periodic.rs@@ -44,14 +44,13 @@ fn last_poll_map() -> &'static LastPollMap {}/// The poll-tracking key for `source_id` in the current storage scope: the-/// same source id in two agents' scopes is two different sources.+/// same source id in two tenants' scopes (agents, or SaaS profiles) is two+/// different sources.fn poll_key(source_id: &str) -> String {- let agent = crate::core::runtime::CoreContext::current()- .and_then(|context| context.session_agent().map(str::to_string));- match agent {- Some(agent) => format!("{agent}\u{0}{source_id}"),- None => source_id.to_string(),- }+ crate::core::runtime::tenant_key(+ &crate::core::runtime::tenant::current_tenant_or_isolated("task_sources"),+ source_id,+ )}/// Record a successful (or attempted) poll for a source id.diff --git a/crates/openhuman-core/src/security/devices/bus.rs b/crates/openhuman-core/src/security/devices/bus.rsindex d2dc9ef608..1bcff05701 100644--- a/crates/openhuman-core/src/security/devices/bus.rs+++ b/crates/openhuman-core/src/security/devices/bus.rs@@ -386,8 +386,9 @@ async fn handle_tunnel_frame(channel_id: &str, payload_b64: &str) {Ok(device) => {super::owner::remember(channel_id,- crate::core::runtime::CoreContext::current()- .and_then(|context| context.session_agent().map(str::to_string)),+ crate::core::runtime::current_tenant()+ .ok()+ .and_then(|tenant| tenant.agent),);log::info!("[devices/bus] device persisted channel_id={} label={}",diff --git a/crates/openhuman-core/src/security/devices/rpc.rs b/crates/openhuman-core/src/security/devices/rpc.rsindex f4558da194..cc5a79dbd1 100644--- a/crates/openhuman-core/src/security/devices/rpc.rs+++ b/crates/openhuman-core/src/security/devices/rpc.rs@@ -137,8 +137,9 @@ pub async fn devices_create_pairing(core_pubkey: core_pubkey.clone(),rpc_url: rpc_url.clone(),expires_at: expires_at.clone(),- agent: crate::core::runtime::CoreContext::current()- .and_then(|context| context.session_agent().map(str::to_string)),+ agent: crate::core::runtime::current_tenant()+ .ok()+ .and_then(|tenant| tenant.agent),},);diff --git a/crates/openhuman-core/src/storage/agents.rs b/crates/openhuman-core/src/storage/agents.rsindex 289f5292ab..340e4a259e 100644--- a/crates/openhuman-core/src/storage/agents.rs+++ b/crates/openhuman-core/src/storage/agents.rs@@ -136,7 +136,8 @@ pub fn contexts() -> Vec<(String, Arc<CoreContext>)> {} else {installed()};- contexts_in(backend, CoreContext::current().as_ref())+ let fallback = crate::core::runtime::tenant::context_in(crate::core::runtime::mode::is_saas());+ contexts_in(backend, fallback.as_ref())}/// [`contexts`] with the backend whose recorded agents are visited, and the@@ -168,7 +169,7 @@ pub fn context_for(agent: &str) -> Option<Arc<CoreContext>> {if crate::core::runtime::mode::is_saas() {return None;}- CoreContext::current().map(|current| current.for_agent(agent))+ crate::core::runtime::tenant::context_in(false).map(|current| current.for_agent(agent))})}