Skip to content

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

test(threads): release the purge test's gated child only after purge settles it

M3gA-Mind0e9166e8e6e9
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 b61453ff14..5a5619b7f7 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
@@ -665,14 +665,11 @@ async fn purging_threads_cancels_driver_children_and_discards_completions() {
1,
"the purge starts with a queued child completion"
);
- let release_after_cancel = {
- let release = release.clone();
- tokio::spawn(async move {
- tokio::time::sleep(std::time::Duration::from_millis(100)).await;
- release.notify_one();
- })
- };
-
+ // Keep the child gated until purge has settled it. The harness races the
+ // in-flight model call against the job's cancellation token, so purge's
+ // cancel unwinds the child without a release. Releasing on a timer let the
+ // child complete on its own before purge cancelled it whenever purge's
+ // admission and fencing took longer than the timer.
tokio::time::timeout(
std::time::Duration::from_secs(6),
crate::threads::ops::threads_purge(&dispatch, crate::threads::EmptyRequest {}),
@@ -712,7 +709,5 @@ async fn purging_threads_cancels_driver_children_and_discards_completions() {
.is_empty(),
"settled purge releases active child owner slots"
);
- release_after_cancel
- .await
- .expect("child release task completes");
+ release.notify_one();
}