Skip to content

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

fix(memory): avoid moving state and borrow owner in write fence

Steven Enamakel047607eb6978
diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs b/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
index 3ecbfef3fd..2f63f62617 100644
--- a/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/jobs_tests.rs
@@ -21,7 +21,9 @@ fn workspace_queues_are_released_after_the_last_holder_drops() {
drop(queue_of(&sentinel));
let queues = QUEUES.lock().unwrap();
- assert!(workspaces.iter().all(|workspace| !queues.contains_key(workspace)));
+ assert!(workspaces
+ .iter()
+ .all(|workspace| !queues.contains_key(workspace)));
}
fn build(agent: &str) -> BackgroundJob {
diff --git a/crates/openhuman-core/src/memory/tool_writes.rs b/crates/openhuman-core/src/memory/tool_writes.rs
index eb4dd63f2a..66e002e3d7 100644
--- a/crates/openhuman-core/src/memory/tool_writes.rs
+++ b/crates/openhuman-core/src/memory/tool_writes.rs
@@ -468,7 +468,7 @@ pub(crate) async fn fence_and_clear(
let mut fence = WriteFence {
guard: None,
token: Some(token),
- state,
+ state: state.clone(),
config: Arc::new(config.clone()),
ctx: ctx.clone(),
};
@@ -565,7 +565,7 @@ pub(crate) async fn drain(config: &Config) -> usize {
let state = drain_state(&file);
let _draining = state.barrier.lock().await;
let generation = owner.gate.generation();
- drain_locked(config, &file, owner, generation).await
+ drain_locked(config, &file, &owner, generation).await
}
/// Runs one queued write against the bound engine, bounded by [`WRITE_TIMEOUT`].
diff --git a/crates/openhuman-core/src/memory/tool_writes_tests.rs b/crates/openhuman-core/src/memory/tool_writes_tests.rs
index ea497734ad..4d9bea075d 100644
--- a/crates/openhuman-core/src/memory/tool_writes_tests.rs
+++ b/crates/openhuman-core/src/memory/tool_writes_tests.rs
@@ -41,7 +41,11 @@ fn owner_states_are_released_after_the_last_write_holder_drops() {
..config_in(&temp)
};
drop(owner_state(&sentinel_config));
- drop(queue(&sentinel_workspace.join("memory").join("sentinel-writes.json")));
+ drop(queue(
+ &sentinel_workspace
+ .join("memory")
+ .join("sentinel-writes.json"),
+ ));
let owners = OWNERS.lock().unwrap();
assert!(keys.iter().all(|key| !owners.contains_key(key)));