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
chore(runtime): remove debug leak-tracking instrumentation
Steven Enamakel58169a19ce7d
diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rsindex b6ab56aeee..816f190c2d 100644--- a/crates/openhuman-core/src/core/runtime/context.rs+++ b/crates/openhuman-core/src/core/runtime/context.rs@@ -268,7 +268,6 @@ impl CoreContext {}};let agent = self.agent.derive(&mut overlay, fresh_state);- let dbg_shares = !fresh_state && overlay.session_agent.is_none() && overlay.profile.is_none();config_access::record_context_config_overlay(self.profile(), parent_config, &mut overlay);overlay.config.runtime_state.context_snapshot = None;let latest_embedder_config = Some(Arc::new(std::sync::Mutex::new(overlay.config.clone())));@@ -284,7 +283,7 @@ impl CoreContext {} else {Arc::new(())};- let dbg_new = Arc::new(CoreContext {+ Arc::new(CoreContext {host_kind: self.host_kind,workspace_binding: RwLock::new(shared_binding),domains,@@ -308,9 +307,7 @@ impl CoreContext {profile_admission,agent,bare: self.bare,- });- if dbg_shares { DBG_DERIVED.lock().unwrap().push((Arc::downgrade(&dbg_new), std::backtrace::Backtrace::force_capture().to_string())); }- dbg_new+ })}/// The agent a host session store scopes work under this context to, if@@ -513,5 +510,3 @@ mod test_support;#[cfg(test)]#[path = "context_tests.rs"]mod tests;--pub static DBG_DERIVED: std::sync::Mutex<Vec<(std::sync::Weak<CoreContext>, String)>> = std::sync::Mutex::new(Vec::new());diff --git a/crates/openhuman-core/src/core/runtime/context_agent.rs b/crates/openhuman-core/src/core/runtime/context_agent.rsindex d9b3568a44..b487f72352 100644--- a/crates/openhuman-core/src/core/runtime/context_agent.rs+++ b/crates/openhuman-core/src/core/runtime/context_agent.rs@@ -90,8 +90,6 @@ impl CoreContext {////// A host must not close or evict a tenant while this is `true`: its/// in-flight tables (turns, queues, caches) live in those slots.- pub fn debug_counts(self: &Arc<Self>) -> usize { let n = Arc::strong_count(&self.agent.state); if n > 1 { for (t, w, bt) in crate::core::runtime::dispatch_ctx::DBG_TRACK.lock().unwrap().iter() { if t.strong_count() > 0 { if let Some(c) = w.upgrade() { if Arc::ptr_eq(&c.agent.state, &self.agent.state) { for l in bt.lines().filter(|l| l.contains("openhuman") && !l.trim_start().starts_with("at ")).take(9) { log::warn!("DBGHOLD {}", l.trim()); } log::warn!("DBGHOLD ----"); } } } } for (w, bt) in super::DBG_DERIVED.lock().unwrap().iter() { if let Some(c) = w.upgrade() { if Arc::ptr_eq(&c.agent.state, &self.agent.state) && !Arc::ptr_eq(&c, self) { for l in bt.lines().filter(|l| l.contains("openhuman") && !l.trim_start().starts_with("at ")).take(12) { log::warn!("DBGLEAK {}", l.trim()); } } } } } n }-pub fn tenant_in_use(self: &Arc<Self>) -> bool {Arc::strong_count(self) > 1 || Arc::strong_count(&self.agent.state) > 1}diff --git a/crates/openhuman-core/src/core/runtime/context_turn_origin.rs b/crates/openhuman-core/src/core/runtime/context_turn_origin.rsindex 70406962a2..5471c5dce5 100644--- a/crates/openhuman-core/src/core/runtime/context_turn_origin.rs+++ b/crates/openhuman-core/src/core/runtime/context_turn_origin.rs@@ -96,7 +96,7 @@ impl CoreContext {origin: Option<crate::security::turn_origin::AgentTurnOrigin>,) -> Arc<CoreContext> {let ctx = self;- let dbg_new = Arc::new(CoreContext {+ Arc::new(CoreContext {host_kind: ctx.host_kind,workspace_binding: RwLock::new(ctx.workspace_binding@@ -120,8 +120,6 @@ impl CoreContext {profile_admission: Arc::clone(&ctx.profile_admission),agent: ctx.agent.clone(),bare: ctx.bare,- });- super::DBG_DERIVED.lock().unwrap().push((Arc::downgrade(&dbg_new), std::backtrace::Backtrace::force_capture().to_string()));- dbg_new+ })}}diff --git a/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs b/crates/openhuman-core/src/core/runtime/dispatch_ctx.rsindex 27045fff84..1ffb7bc8c5 100644--- a/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs+++ b/crates/openhuman-core/src/core/runtime/dispatch_ctx.rs@@ -21,18 +21,10 @@ use super::CoreContext;/// Cheap to clone (one `Arc`). It is `unbound` only when no [`CoreContext`]/// exists at all: a unit test that never booted the core, or a call made/// before boot. A booted host always dispatches with a bound context.-#[derive(Default)]+#[derive(Clone, Default)]pub struct DispatchCtx {core: Option<Arc<CoreContext>>,headless_agent_chat: bool,- track: Option<Arc<()>>,-}-pub static DBG_TRACK: std::sync::Mutex<Vec<(std::sync::Weak<()>, std::sync::Weak<CoreContext>, String)>> = std::sync::Mutex::new(Vec::new());-impl Clone for DispatchCtx {- fn clone(&self) -> Self {- let track = self.core.as_ref().map(|c| { let t = Arc::new(()); DBG_TRACK.lock().unwrap().push((Arc::downgrade(&t), Arc::downgrade(c), std::backtrace::Backtrace::force_capture().to_string())); t });- Self { core: self.core.clone(), headless_agent_chat: self.headless_agent_chat, track }- }}impl DispatchCtx {@@ -42,7 +34,6 @@ impl DispatchCtx {Self {core: Some(core),headless_agent_chat: false,- track: None,}}@@ -60,7 +51,6 @@ impl DispatchCtx {Self {core: None,headless_agent_chat: false,- track: None,}}@@ -71,7 +61,6 @@ impl DispatchCtx {Self {core: CoreContext::default_context(),headless_agent_chat: false,- track: None,}}@@ -92,7 +81,6 @@ impl DispatchCtx {Self {core,headless_agent_chat: false,- track: None,}}@@ -165,7 +153,6 @@ impl DispatchCtx {Self {core: CoreContext::scoped_for_turn(),headless_agent_chat: false,- track: None,}}diff --git a/crates/openhuman-core/src/profiles/capabilities.rs b/crates/openhuman-core/src/profiles/capabilities.rsindex 7ceb1ba273..7ee7587a73 100644--- a/crates/openhuman-core/src/profiles/capabilities.rs+++ b/crates/openhuman-core/src/profiles/capabilities.rs@@ -168,7 +168,7 @@ impl ProfileCapabilities {// Native construction stays inside the domains registered for this// profile. The named packs narrow registration within those domains.let assembly =- ctx.derive_for_inspection(ContextOverlay::new(config.clone(), ctx.domains(), groups));+ ctx.derive_with(ContextOverlay::new(config.clone(), ctx.domains(), groups));let security = Arc::new(crate::security::SecurityPolicy::from_config(&config.autonomy,&config.workspace_dir,diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rsindex 1037bc3434..896124bfd4 100644--- a/crates/openhuman-core/src/profiles/host.rs+++ b/crates/openhuman-core/src/profiles/host.rs@@ -638,7 +638,6 @@ impl ProfileHost {/// or a turn still running on its context (a detached turn outlives the/// request that started it).fn in_use(slot: &Slot) -> bool {- log::warn!("DBGINUSE {} slotstate={} ctx={} agent={}", slot.state.id, Arc::strong_count(&slot.state), Arc::strong_count(&slot.state.context), slot.state.context.debug_counts());Arc::strong_count(&slot.state) > 1 || slot.state.context.tenant_in_use()}diff --git a/crates/openhuman-core/src/web_chat/session.rs b/crates/openhuman-core/src/web_chat/session.rsindex 6385b6b081..fa0570287a 100644--- a/crates/openhuman-core/src/web_chat/session.rs+++ b/crates/openhuman-core/src/web_chat/session.rs@@ -586,7 +586,6 @@ pub(crate) async fn checkin_session_agent(fingerprint: SessionCacheFingerprint,) {let mut sessions = super::ops::thread_sessions(ctx).lock_owned().await;- if std::env::var("DBG_NOCACHE").is_ok() { drop(agent); let _ = fingerprint; return; }sessions.insert(super::ops::key_for(ctx, thread_id),SessionEntry { agent, fingerprint },