Skip to content

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

docs(agent): clarify mcp cleanup guard lifetime

Steven Enamakelc210b8378baa
diff --git a/crates/openhuman-embed/src/agent/mcp_cleanup.rs b/crates/openhuman-embed/src/agent/mcp_cleanup.rs
index 3ff76b5d63..ef6a09483f 100644
--- a/crates/openhuman-embed/src/agent/mcp_cleanup.rs
+++ b/crates/openhuman-embed/src/agent/mcp_cleanup.rs
@@ -32,8 +32,9 @@ pub(crate) fn finish_removal(
/// Run at most three retries on the process module executor. The future owns
/// 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.
+/// 750 ms of backoff, plus synchronous filesystem purge. Purge and executor
+/// scheduling are outside the MCP wait bound. Retained records contain no
+/// guard; the last guard keeps runtime admission reserved through completion.
pub(crate) fn defer_pending(
registry: Arc<crate::runtime::AgentMap>,
id: String,
@@ -92,7 +93,9 @@ fn complete_with_guard<T>(
guard: &mut Option<Arc<crate::runtime::CoreGuard>>,
complete: impl FnOnce() -> T,
) -> T {
- drop(guard.take());
+ // Releasing the last guard permits a new runtime with another agent map
+ // to reopen this workspace. Keep admission reserved through the callback.
+ let _guard = guard.take();
complete()
}