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(flows): thread dispatch context into config_for_scope
Steven Enamakel7e4636c91746
diff --git a/crates/openhuman-core/src/flows/bus/dedup_commit.rs b/crates/openhuman-core/src/flows/bus/dedup_commit.rsindex c49638fb55..22a117b160 100644--- a/crates/openhuman-core/src/flows/bus/dedup_commit.rs+++ b/crates/openhuman-core/src/flows/bus/dedup_commit.rs@@ -202,7 +202,7 @@ impl DedupCommitSubscriber {/// a schema + call-site change bigger than this PR's scope; reported as a/// follow-up rather than attempted here.fn dedup_node_ids(&self, flow_id: &str) -> Vec<String> {- match store::get_flow(&super::owner::config_for_scope(&self.config), flow_id) {+ match store::get_flow(&super::owner::config_for_scope(&crate::core::runtime::DispatchCtx::ambient(), &self.config), flow_id) {Ok(Some(flow)) => flow.graph.nodes@@ -223,7 +223,7 @@ impl DedupCommitSubscriber {async fn handle_finished(&self, flow_id: &str, run_id: &str, status: &str) {// As the flow's owner: its own configuration (`super::owner`).- let config = super::owner::config_for_scope(&self.config);+ let config = super::owner::config_for_scope(&crate::core::runtime::DispatchCtx::ambient(), &self.config);let node_ids = self.dedup_node_ids(flow_id);if node_ids.is_empty() {tracing::trace!(target: "flows", %flow_id, %run_id, %status, "[dedup-commit] no dedup nodes in this flow — nothing to settle");diff --git a/crates/openhuman-core/src/flows/bus/owner.rs b/crates/openhuman-core/src/flows/bus/owner.rsindex aea3486f50..1800070838 100644--- a/crates/openhuman-core/src/flows/bus/owner.rs+++ b/crates/openhuman-core/src/flows/bus/owner.rs@@ -101,11 +101,15 @@ pub(super) async fn as_owner<F: std::future::Future<Output = ()>>(/// when the handler runs as one ([`as_owner`]) — its provider, access/// policy, memory and action directory — else `registered`, the one the/// subscriber was registered with.-pub(super) fn config_for_scope(registered: &std::sync::Arc<Config>) -> std::sync::Arc<Config> {+pub(super) fn config_for_scope(+ ctx: &crate::core::runtime::DispatchCtx,+ registered: &std::sync::Arc<Config>,+) -> std::sync::Arc<Config> {// A SaaS profile acts as its own tenant even with no agent inside it.- let acting = crate::core::runtime::current_tenant()+ let acting = ctx+ .tenant().is_ok_and(|tenant| tenant.agent.is_some() || tenant.profile.is_some());- match acting.then(crate::core::runtime::CoreContext::current_embedder_config) {+ match acting.then(|| ctx.embedder_config()) {Some(Some(config)) => std::sync::Arc::new(config),_ => std::sync::Arc::clone(registered),}diff --git a/crates/openhuman-core/src/flows/bus/run_digest.rs b/crates/openhuman-core/src/flows/bus/run_digest.rsindex b2dc892af0..d5eee797b3 100644--- a/crates/openhuman-core/src/flows/bus/run_digest.rs+++ b/crates/openhuman-core/src/flows/bus/run_digest.rs@@ -61,7 +61,7 @@ impl FlowRunDigestSubscriber {async fn handle_finished(&self, flow_id: &str, run_id: &str, status: &str) {// As the flow's owner: its own configuration (`super::owner`).- let config = super::owner::config_for_scope(&self.config);+ let config = super::owner::config_for_scope(&crate::core::runtime::DispatchCtx::ambient(), &self.config);if status != "completed" && status != "completed_with_warnings" {tracing::trace!(target: "flows", %flow_id, %run_id, %status, "[flows] digest: ignoring non-success terminal status");return;diff --git a/crates/openhuman-core/src/flows/bus/trigger.rs b/crates/openhuman-core/src/flows/bus/trigger.rsindex e48a4f1d00..da0b6d1de0 100644--- a/crates/openhuman-core/src/flows/bus/trigger.rs+++ b/crates/openhuman-core/src/flows/bus/trigger.rs@@ -113,7 +113,7 @@ impl FlowTriggerSubscriber {/// The configuration to handle an event under (`super::owner::config_for_scope`).pub(super) fn config_for_scope(&self) -> Arc<Config> {- super::owner::config_for_scope(&self.config)+ super::owner::config_for_scope(&crate::core::runtime::DispatchCtx::ambient(), &self.config)}/// A `flow`-type cron job fired (`cron::scheduler`'s trigger sink calls