Skip to content

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

test(threads): update background completion assertions for workspace-scoped API

Steven Enamakele9aa9c09a292
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
index d70e7deac2..2d81fc3947 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
@@ -178,12 +178,13 @@ async fn archetype_delegation_defaults_to_async_with_durable_session_e2e() {
);
// Completion queued for delivery back into the parent chat as a new turn.
assert!(
- crate::agent::orchestration::background_completions::has_pending("tools-e2e-async-session"),
+ !crate::agent::orchestration::background_completions::pending_for(
+ workspace.path(),
+ "thread-async-parent",
+ )
+ .is_empty(),
"finished result queued for background delivery"
);
- let _ = crate::agent::orchestration::background_completions::take_pending(
- "tools-e2e-async-session",
- );
}
#[tokio::test]
@@ -323,9 +324,6 @@ async fn continue_subagent_resumes_idle_durable_session_e2e() {
provider.saw("original task from an earlier turn"),
"persisted history was replayed into the resumed run"
);
- let _ = crate::agent::orchestration::background_completions::take_pending(
- "tools-e2e-continue-session",
- );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/threads/ops_conversion_tests.rs b/crates/openhuman-core/src/threads/ops_conversion_tests.rs
index 6c705e68e8..5e7d4dd05b 100644
--- a/crates/openhuman-core/src/threads/ops_conversion_tests.rs
+++ b/crates/openhuman-core/src/threads/ops_conversion_tests.rs
@@ -351,14 +351,19 @@ async fn thread_delete_removes_persisted_turn_state_snapshot() {
// Queue a finished background sub-agent result for this thread; deleting the
// thread must discard it so it's never delivered into a dead thread.
use crate::agent::orchestration::background_completions as bg;
+ // A child registered on the thread first, which is how the thread's
+ // completions are located when it is deleted.
+ bg::mark_stopped_task_if_thread_stopped(&dir, thread_id, "sub-del-1");
bg::record_completion(
+ &dir,
"sess-del",
"sub-del-1",
"researcher",
"result",
Some(thread_id.to_string()),
- );
- assert_eq!(bg::pending_count("sess-del"), 1);
+ )
+ .await;
+ assert_eq!(bg::pending_for(&dir, thread_id).len(), 1);
thread_delete(DeleteConversationThreadRequest {
thread_id: thread_id.to_string(),
@@ -368,7 +373,7 @@ async fn thread_delete_removes_persisted_turn_state_snapshot() {
.expect("delete thread");
assert_eq!(
- bg::pending_count("sess-del"),
+ bg::pending_for(&dir, thread_id).len(),
0,
"queued completion for the deleted thread should be discarded"
);
@@ -408,26 +413,30 @@ async fn threads_purge_removes_valid_and_corrupted_turn_state_files() {
// them all since no parent thread survives.
use crate::agent::orchestration::background_completions as bg;
bg::record_completion(
+ &dir,
"sess-p1",
"sub-p1",
"researcher",
"x",
Some("thread-a".into()),
- );
+ )
+ .await;
bg::record_completion(
+ &dir,
"sess-p2",
"sub-p2",
"researcher",
"y",
Some("thread-b".into()),
- );
+ )
+ .await;
threads_purge(EmptyRequest {})
.await
.expect("purge threads should also clear snapshots");
- assert!(!bg::has_pending("sess-p1"));
- assert!(!bg::has_pending("sess-p2"));
+ assert!(bg::pending_for(&dir, "thread-a").is_empty());
+ assert!(bg::pending_for(&dir, "thread-b").is_empty());
if turn_state_dir.exists() {
let remaining_json: Vec<_> = std::fs::read_dir(&turn_state_dir)