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(inbound): route background work through the host dispatch context
Steven Enamakel2d558830b0d6
diff --git a/crates/openhuman-core/src/inbound/deliver.rs b/crates/openhuman-core/src/inbound/deliver.rsindex 0be8d81815..49556edc2e 100644--- a/crates/openhuman-core/src/inbound/deliver.rs+++ b/crates/openhuman-core/src/inbound/deliver.rs@@ -369,7 +369,7 @@ impl Deliverer {let runner = Arc::clone(&self.runner);let ctx = self.ctx.clone();let label = envelope.display_label.clone();- let mut task = tokio::spawn(async move {+ let mut task = self.ctx.spawn(async move {let applied = runner.apply(&ctx, run, &envelope).await;if let Err(error) = &applied {// Reported here, wherever the delivery stands: inside thediff --git a/crates/openhuman-core/src/inbound/settings.rs b/crates/openhuman-core/src/inbound/settings.rsindex 11964ed8db..cc5dd5a744 100644--- a/crates/openhuman-core/src/inbound/settings.rs+++ b/crates/openhuman-core/src/inbound/settings.rs@@ -129,13 +129,13 @@ fn refuse_plaintext_credentials(url: &str) -> Result<(), String> {}/// The last resolution, read by the storage host's grant and by `Deliver`.-static CURRENT: RwLock<Option<Arc<Resolved>>> = RwLock::new(None);+static LAST_RESOLUTION: RwLock<Option<Arc<Resolved>>> = RwLock::new(None);/// The resolution the module was last configured with, or the shipped one.#[must_use]pub fn current() -> Arc<Resolved> {static SHIPPED: std::sync::OnceLock<Arc<Resolved>> = std::sync::OnceLock::new();- let guard = CURRENT+ let guard = LAST_RESOLUTION.read().unwrap_or_else(std::sync::PoisonError::into_inner);guard@@ -145,7 +145,7 @@ pub fn current() -> Arc<Resolved> {fn remember(resolved: Resolved) -> Arc<Resolved> {let resolved = Arc::new(resolved);- *CURRENT+ *LAST_RESOLUTION.write().unwrap_or_else(std::sync::PoisonError::into_inner) = Some(Arc::clone(&resolved));resolveddiff --git a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rsindex 12c2912f06..e08a7ecbaf 100644--- a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs+++ b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs@@ -190,7 +190,8 @@ impl EventHandler<DomainEvent> for ComposioTriggerSubscriber {// Its own task: the hand-off may wait for the module's first load and// retries an unanswered ingest, which must never hold up this// subscriber's loop (a stalled loop lags and loses broadcast events).- tokio::spawn(async move {+ let spawner = ctx.clone();+ spawner.spawn(async move {let config = ctx.load_config().await.ok();route_trigger(ctx,diff --git a/crates/openhuman-core/src/modules/boot.rs b/crates/openhuman-core/src/modules/boot.rsindex aaf6526496..6dae3b227f 100644--- a/crates/openhuman-core/src/modules/boot.rs+++ b/crates/openhuman-core/src/modules/boot.rs@@ -97,7 +97,8 @@ fn warm_inbound_queues(config: &Config) {return;}let config = config.clone();- tokio::spawn(async move {+ // Loading a module is process-wide; the host's own context carries it.+ crate::core::runtime::DispatchCtx::host_default().spawn(async move {log::debug!("[modules] inbound event queues warm-up starting");if let Err(reason) = ops::ensure_loaded(&config, super::event_queues::MODULE_ID).await {log::warn!("[modules] inbound event queues did not load at boot: {reason}");diff --git a/crates/openhuman-core/src/skills/webhooks/bus.rs b/crates/openhuman-core/src/skills/webhooks/bus.rsindex c978cd92d5..a3df80a7b8 100644--- a/crates/openhuman-core/src/skills/webhooks/bus.rs+++ b/crates/openhuman-core/src/skills/webhooks/bus.rs@@ -137,7 +137,8 @@ impl EventHandler<DomainEvent> for WebhookRequestSubscriber {// module's first load nor a resent ingest holds up this// subscriber's loop.let corr = correlation_id.clone();- tokio::spawn(async move {+ let spawner = ctx.clone();+ spawner.spawn(async move {let config = ctx.load_config().await.ok();let queued = route_agent_trigger(config,