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
fix(mcp): release client cache lock before cleanup callback
Steven Enamakel673a181501bf
diff --git a/crates/openhuman-core/src/mcp/module_client/cleanup_tests.rs b/crates/openhuman-core/src/mcp/module_client/cleanup_tests.rsindex 1328743c3f..1d889cf314 100644--- a/crates/openhuman-core/src/mcp/module_client/cleanup_tests.rs+++ b/crates/openhuman-core/src/mcp/module_client/cleanup_tests.rs@@ -430,7 +430,19 @@ fn cleanup_callback_can_access_the_client_cache() {McpConfiguredClient::schedule_agent_close_and_cleanup(workspace.path(),Arc::new(move || {- callback_flag.store(CLIENTS.get().unwrap().try_lock().is_ok(), Ordering::SeqCst);+ // Permit transient contention from other parallel tests, while+ // detecting a cache lock held by the cleanup call itself.+ let deadline = std::time::Instant::now() + Duration::from_secs(10);+ let available = loop {+ if CLIENTS.get().unwrap().try_lock().is_ok() {+ break true;+ }+ if std::time::Instant::now() >= deadline {+ break false;+ }+ std::thread::yield_now();+ };+ callback_flag.store(available, Ordering::SeqCst);true}),);diff --git a/crates/openhuman-core/src/mcp/module_client/lifecycle.rs b/crates/openhuman-core/src/mcp/module_client/lifecycle.rsindex 4df9fb6549..dc9d385026 100644--- a/crates/openhuman-core/src/mcp/module_client/lifecycle.rs+++ b/crates/openhuman-core/src/mcp/module_client/lifecycle.rs@@ -398,7 +398,7 @@ impl McpConfiguredClient {if !is_current {return false;}- let mut clients = if let Some(client) = client.as_ref() {+ if let Some(client) = client.as_ref() {let Some(clients) = CLIENTS.get() else {return false;};@@ -411,14 +411,25 @@ impl McpConfiguredClient {{return false;}- Some(clients)- } else {- None- };+ }+ // The reservation still blocks admission for this directory while+ // the callback runs without the global client cache lock.if after_close.as_ref().is_some_and(|action| !action()) {return false;}- if let Some(clients) = clients.as_mut() {+ if let Some(client) = client.as_ref() {+ let Some(clients) = CLIENTS.get() else {+ return false;+ };+ let mut clients = clients+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner);+ if !clients+ .get(data_dir)+ .is_some_and(|current| Arc::ptr_eq(current, client))+ {+ return false;+ }clients.remove(data_dir);}let mut reservations = reservations