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(background_delivery): move delivering registry to parent module
Steven Enamakel07f2ea24ab23
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery.rsindex 99c88611e3..eaa719b1de 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs@@ -65,6 +65,13 @@ const DEBOUNCE: Duration = Duration::from_secs(3);/// delivery turn, so providers and the session store are up first.const RECOVERY_DELAY: Duration = Duration::from_secs(15);+/// Threads whose delivery turn is in flight — prevents two concurrent turns.+/// Keyed by [`tenant::profile_key`] of the thread id, for the same reason.+fn delivering() -> &'static Mutex<HashSet<String>> {+ static D: OnceLock<Mutex<HashSet<String>>> = OnceLock::new();+ D.get_or_init(|| Mutex::new(HashSet::new()))+}+/// Ask for a delivery attempt on `thread_id` soon (after a Stop cleared a stale/// busy mark, or anything else that may have left a drain without its trigger).pub(crate) fn kick_delivery(thread_id: &str) {diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rsindex bfabbc4017..fcaa954620 100644--- a/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery/slot.rs@@ -1,21 +1,13 @@//! The per-thread (per profile) delivery slot: at most one delivery turn is in//! flight for a thread, and the batch it claimed is leased until it settles.-use std::collections::HashSet;-use std::sync::{Arc, Mutex, OnceLock};+use std::sync::Arc;use tinyagents_tasks::CompletionRouter;use crate::core::runtime::tenant;use crate::core::runtime::DispatchCtx;-/// Threads whose delivery turn is in flight — prevents two concurrent turns.-/// Keyed by [`tenant::profile_key`] of the thread id, for the same reason.-pub(super) fn delivering() -> &'static Mutex<HashSet<String>> {- static D: OnceLock<Mutex<HashSet<String>>> = OnceLock::new();- D.get_or_init(|| Mutex::new(HashSet::new()))-}-/// The per-thread (per profile) delivery slot, plus the batch lease./// Dropping it frees both: `release` on an already-settled record is a no-op,/// so a settled batch is untouched and an abandoned one is claimable again.@@ -34,7 +26,7 @@ impl DeliverySlot {router: Arc<CompletionRouter>,) -> Option<Self> {let key = tenant::profile_key_in(&super::super::busy_guard::caller(ctx), thread_id);- let mut d = delivering().lock().expect("delivering poisoned");+ let mut d = super::delivering().lock().expect("delivering poisoned");if !d.insert(key.clone()) {return None;}@@ -55,7 +47,7 @@ impl Drop for DeliverySlot {if !self.held.is_empty() {self.router.release(&self.held);}- if let Ok(mut d) = delivering().lock() {+ if let Ok(mut d) = super::delivering().lock() {d.remove(&self.key);}}