Skip to content

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

fix(storage): keep the caller's slot decision across the opener worker

M3gA-Mind64f0f58c4c5c
diff --git a/crates/openhuman-core/src/storage/local.rs b/crates/openhuman-core/src/storage/local.rs
index 4a27b3f4cc..773763fa2f 100644
--- a/crates/openhuman-core/src/storage/local.rs
+++ b/crates/openhuman-core/src/storage/local.rs
@@ -233,7 +233,12 @@ pub fn backend_for(workspace_dir: &Path) -> Result<Arc<dyn StorageBackend>> {
if let Some(backend) = installed() {
return Ok(backend);
}
+ workspace_default(workspace_dir)
+}
+/// The workspace's own default backend, opened on first use, for a caller that
+/// already found no installed backend.
+fn workspace_default(workspace_dir: &Path) -> Result<Arc<dyn StorageBackend>> {
let cell = workspace_backend(workspace_dir);
if let Some(backend) = cell.get() {
return Ok(Arc::clone(backend));
@@ -265,7 +270,9 @@ pub async fn backend_for_async(workspace_dir: &Path) -> Result<Arc<dyn StorageBa
if super::ON_STORAGE_RUNTIME.with(std::cell::Cell::get) {
return initialized_backend(cell, workspace_dir).await;
}
- tokio::task::spawn_blocking(move || backend_for(&workspace_dir))
+ // This call already found no installed backend; the worker opens the
+ // workspace default rather than asking again from another thread.
+ tokio::task::spawn_blocking(move || workspace_default(&workspace_dir))
.await
.context("join the workspace storage opener")?
}
diff --git a/crates/openhuman-core/src/storage/mod.rs b/crates/openhuman-core/src/storage/mod.rs
index 35f177e803..a65b5391f1 100644
--- a/crates/openhuman-core/src/storage/mod.rs
+++ b/crates/openhuman-core/src/storage/mod.rs
@@ -432,11 +432,13 @@ pub fn installed() -> Option<Arc<dyn StorageBackend>> {
/// Removes the installed backend; returns whether there was one.
pub fn clear() -> bool {
- #[cfg(test)]
- set_slot_owner(None);
set_installed_url(None);
agents::reset_recorded();
- BACKEND.clear()
+ let cleared = BACKEND.clear();
+ // Only after the backend is gone, so other tests never see it in between.
+ #[cfg(test)]
+ set_slot_owner(None);
+ cleared
}
/// The storage scope of the current call: the tenant's profile