Skip to content

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

fix(threads): keep deletion fence after successful thread delete

Steven Enamakeld7e2f5e4c8b3
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners.rs
index 8e09ee485c..1b1925385c 100644
--- a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs
+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners.rs
@@ -162,7 +162,7 @@ pub(crate) fn begin_thread_deletion(
Ok(())
}
-/// Release a deletion fence after either delete failure or durable parent closure.
+/// Release a temporary deletion fence when the conversation delete itself failed.
pub(crate) fn release_thread_deletion(
ctx: &crate::core::runtime::DispatchCtx,
workspace_dir: &std::path::Path,
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs
index b1532e95a8..f89c2d88e3 100644
--- a/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners_tests.rs
@@ -62,14 +62,12 @@ fn deleting_thread_refuses_late_owner_registration_but_keeps_prior_owner() {
));
let late = owner("late");
- let result = remember_active_driver_task(
- &mut st,
- "late".into(),
- late,
- ACTIVE_DRIVER_TASKS_CAP,
- );
+ let result = remember_active_driver_task(&mut st, "late".into(), late, ACTIVE_DRIVER_TASKS_CAP);
- assert!(result.is_err(), "a child cannot enter after deletion fences admission");
+ assert!(
+ result.is_err(),
+ "a child cannot enter after deletion fences admission"
+ );
assert!(
st.driver_tasks.contains_key(&existing_key),
"deletion still sees owners admitted before its fence"
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_resume_owner_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_resume_owner_tests.rs
index 5f0d80d716..d1325dd27a 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_resume_owner_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_resume_owner_tests.rs
@@ -167,10 +167,9 @@ async fn resuming_after_owner_cache_loss_registers_live_task_before_launch() {
)
.iter()
.any(|(owner_task_id, _)| owner_task_id == &task_id);
- let resumed_owner = crate::agent::orchestration::completion_owners::driver_task_owner(
- &dispatch, &task_id,
- )
- .expect("resumed task retains its parent scope");
+ let resumed_owner =
+ crate::agent::orchestration::completion_owners::driver_task_owner(&dispatch, &task_id)
+ .expect("resumed task retains its parent scope");
let owner_key = crate::agent::tinyagents::tool_registration::subagent_owner_key(
&resumed_owner.workspace_dir,
&resumed_owner.parent_session,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_thread_delete_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_thread_delete_tests.rs
index fb1f52dfc4..b8ab859fd7 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_thread_delete_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_thread_delete_tests.rs
@@ -221,6 +221,18 @@ async fn deleting_parent_thread_cancels_driver_child_before_discarding_completio
.is_empty(),
"settled thread deletion releases active child owner slots"
);
+ assert!(
+ crate::agent::orchestration::completion_owners::note_driver_task(
+ &dispatch,
+ "late-child-after-parent-delete",
+ workspace.clone(),
+ workspace_descriptor.clone(),
+ parent_session.into(),
+ Some(thread_id.into()),
+ )
+ .is_err(),
+ "the permanent deletion fence refuses children that race after the sweep"
+ );
assert!(
background_completions::pending_for(&workspace, thread_id).is_empty(),
"queued child completions are discarded after cancellation"
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index f25b2b1f49..13365276ed 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -525,11 +525,6 @@ async fn thread_delete_inner(
&dir,
&request.thread_id,
);
- crate::agent::orchestration::completion_owners::release_thread_deletion(
- &ctx,
- &dir,
- &request.thread_id,
- );
log::debug!(
"[threads] thread_delete thread_id={} cancelled_subagents={} discarded_completions={}",
request.thread_id,