Skip to content

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

test(cron): wait for child acknowledgement before asserting timeout

Steven Enamakel716e434fc35e
diff --git a/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs b/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs
index 9f9767615d..c5f7e60256 100644
--- a/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs
@@ -17,6 +17,7 @@ struct CronChildModel {
child_calls: std::sync::atomic::AtomicUsize,
child_invocation_dropped: std::sync::Arc<std::sync::atomic::AtomicBool>,
accepted_followups: std::sync::atomic::AtomicUsize,
+ accepted_followup: tokio::sync::Notify,
child_attempts_dangerous_tool: bool,
child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool,
child_started: std::sync::Mutex<Option<tokio::sync::oneshot::Sender<()>>>,
@@ -164,6 +165,7 @@ impl ChatModel<()> for CronChildModel {
}) {
self.accepted_followups
.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
+ self.accepted_followup.notify_one();
return Ok(ModelResponse::assistant("headless-cron-root-result"));
}
@@ -199,6 +201,7 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {
child_calls: std::sync::atomic::AtomicUsize::new(0),
child_invocation_dropped: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),
accepted_followups: std::sync::atomic::AtomicUsize::new(0),
+ accepted_followup: tokio::sync::Notify::new(),
child_attempts_dangerous_tool: false,
child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),
child_started: std::sync::Mutex::new(None),
@@ -268,6 +271,7 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settle
child_calls: std::sync::atomic::AtomicUsize::new(0),
child_invocation_dropped: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),
accepted_followups: std::sync::atomic::AtomicUsize::new(0),
+ accepted_followup: tokio::sync::Notify::new(),
child_attempts_dangerous_tool: false,
child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),
child_started: std::sync::Mutex::new(None),
@@ -275,7 +279,7 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settle
});
let _model =
crate::inference::provider::factory::test_provider_override::install_model(model.clone());
- let (_temp, config, core, dispatch, job) = scheduled_agent_fixture(2);
+ let (_temp, config, core, dispatch, job) = scheduled_agent_fixture(5);
let inspect_dispatch = dispatch.clone();
let (child_started_tx, child_started_rx) = tokio::sync::oneshot::channel();
*model.child_started.lock().unwrap() = Some(child_started_tx);
@@ -299,7 +303,14 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settle
}
}
- tokio::time::timeout(std::time::Duration::from_secs(5), run)
+ tokio::time::timeout(
+ std::time::Duration::from_secs(4),
+ model.accepted_followup.notified(),
+ )
+ .await
+ .expect("the root acknowledges the spawned child before its deadline");
+
+ tokio::time::timeout(std::time::Duration::from_secs(6), run)
.await
.expect("cron timeout should settle the blocked run")
.expect("cron scheduler task");
@@ -375,6 +386,7 @@ async fn scheduled_cron_child_cannot_run_its_declared_destructive_tool() {
child_calls: std::sync::atomic::AtomicUsize::new(0),
child_invocation_dropped: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),
accepted_followups: std::sync::atomic::AtomicUsize::new(0),
+ accepted_followup: tokio::sync::Notify::new(),
child_attempts_dangerous_tool: true,
child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),
child_started: std::sync::Mutex::new(None),