Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed crates/openhuman-core/src/mcp/agent_cleanup.rs,crates/openhuman-embed/src/agent

Steven Enamakel04f37c1b6a74
diff --git a/crates/openhuman-core/src/mcp/agent_cleanup.rs b/crates/openhuman-core/src/mcp/agent_cleanup.rs
index 98c909ec2c..7324a9e04a 100644
--- a/crates/openhuman-core/src/mcp/agent_cleanup.rs
+++ b/crates/openhuman-core/src/mcp/agent_cleanup.rs
@@ -34,9 +34,13 @@ pub(super) fn agent_is_removed() -> bool {
impl AgentMcpCleanup {
/// Close the original object and evict it only after confirmed cleanup.
- /// Cancellation or error retains the same client and transition receipt.
+ /// The whole attempt, including lock acquisition and bus calls, has a
+ /// 30-second deadline. Timeout returns `TransportFailed`; cancellation or
+ /// error retains the same client and transition receipt for explicit retry.
pub async fn finish(&self) -> Result<(), ModuleCallError> {
- self.client.close().await?;
+ tokio::time::timeout(TRANSITION_TIMEOUT, self.client.close())
+ .await
+ .map_err(|_| ModuleCallError::TransportFailed)??;
self.evict();
Ok(())
}
diff --git a/crates/openhuman-embed/src/agent/mcp_cleanup.rs b/crates/openhuman-embed/src/agent/mcp_cleanup.rs
index bc64b1660c..9d04aae03e 100644
--- a/crates/openhuman-embed/src/agent/mcp_cleanup.rs
+++ b/crates/openhuman-embed/src/agent/mcp_cleanup.rs
@@ -31,7 +31,9 @@ pub(crate) fn finish_removal(
}
/// Run at most three retries on the process module executor. The future owns
-/// the workspace guard only while running; retained records contain no guard.
+/// the workspace guard through at most 90 seconds of polled MCP cleanup and
+/// 750 ms of backoff. It releases the guard before filesystem purge; retained
+/// records contain no guard. Executor scheduling can delay these timed waits.
pub(crate) fn defer_pending(
registry: Arc<crate::runtime::AgentMap>,
id: String,
@@ -54,13 +56,18 @@ pub(crate) fn defer_pending(
let running = Arc::clone(&pending.retry_running);
let executor_failed = Arc::clone(&running);
let future = async move {
- let _guard = guard;
+ let mut guard = Some(guard);
for attempt in 0..3 {
let result = match &pending.cleanup {
Some(cleanup) => cleanup.finish().await.map_err(AgentError::McpCleanup),
None => Ok(()),
- }
- .and_then(|()| finish_removal(&registry, &id, &pending));
+ };
+ let result = result.and_then(|()| {
+ // Confirmed module cleanup no longer needs the process/workspace
+ // owner. Filesystem purge must not extend its retention lifetime.
+ drop(guard.take());
+ finish_removal(&registry, &id, &pending)
+ });
match result {
Ok(()) => {
running.store(false, Ordering::Release);