Skip to content

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

test(cron): improve child start timeout handling

Steven Enamakelab29148372e4
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 b6969fc662..f4aa839fd0 100644
--- a/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs
@@ -111,10 +111,18 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {
super::super::agent_run::run_agent_job_for_run(&dispatch, &config, &job, "cron-run-test")
.await
});
- tokio::time::timeout(std::time::Duration::from_secs(5), child_started_rx)
- .await
- .expect("the scheduled child reaches its model")
- .expect("child-start observation remains connected");
+ match tokio::time::timeout(std::time::Duration::from_secs(5), child_started_rx).await {
+ Ok(Ok(())) => {}
+ Ok(Err(error)) => panic!("child-start observation disconnected: {error}"),
+ Err(_) => {
+ model.child_release.notify_one();
+ let result = tokio::time::timeout(std::time::Duration::from_secs(5), run).await;
+ panic!(
+ "scheduled child never reached its model (spawn calls: {}); run result: {result:?}",
+ model.spawn_calls.load(std::sync::atomic::Ordering::SeqCst)
+ );
+ }
+ }
model.child_release.notify_one();
let (success, output, error) = run.await.expect("cron runner task");