The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(cron): make headless descendant child release sticky
Steven Enamakel82cecc2524a0
diff --git a/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs b/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rsindex 15abebd5fe..05f65f3cd0 100644--- a/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs+++ b/crates/openhuman-core/src/cron/scheduler_headless_descendants_tests.rs@@ -22,6 +22,28 @@ struct CronChildModel {child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool,child_started: std::sync::Mutex<Option<tokio::sync::oneshot::Sender<()>>>,child_release: tokio::sync::Notify,+ child_released: std::sync::atomic::AtomicBool,+}++impl CronChildModel {+ /// Release every current and future child invocation. A bare+ /// `Notify::notify_one` stores a single permit, so a second child model call+ /// (a retry or replayed turn) would park forever and hang the drain.+ fn release_child(&self) {+ self.child_released+ .store(true, std::sync::atomic::Ordering::SeqCst);+ self.child_release.notify_waiters();+ }++ async fn wait_for_release(&self) {+ loop {+ let notified = self.child_release.notified();+ if self.child_released.load(std::sync::atomic::Ordering::SeqCst) {+ return;+ }+ notified.await;+ }+ }}#[cfg(feature = "storage-sqlite")]@@ -160,7 +182,7 @@ impl ChatModel<()> for CronChildModel {let _ = started.send(());}let _drop = ChildInvocationDrop(std::sync::Arc::clone(&self.child_invocation_dropped));- self.child_release.notified().await;+ self.wait_for_release().await;return Ok(ModelResponse::assistant("headless-cron-child-result"));}@@ -214,6 +236,7 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),child_started: std::sync::Mutex::new(None),child_release: tokio::sync::Notify::new(),+ child_released: std::sync::atomic::AtomicBool::new(false),});let _model =crate::inference::provider::factory::test_provider_override::install_model(model.clone());@@ -233,7 +256,7 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {Ok(Ok(())) => {}Ok(Err(error)) => panic!("child-start observation disconnected: {error}"),Err(_) => {- model.child_release.notify_one();+ model.release_child();let result = tokio::time::timeout(std::time::Duration::from_secs(30), run).await;eprintln!("scheduled child start timeout diagnostics: spawn calls {}, followups {}, run result {result:?}",@@ -247,9 +270,19 @@ async fn scheduled_agent_history_includes_its_spawned_child_result() {);}}- model.child_release.notify_one();+ model.release_child();- run.await.expect("cron scheduler task");+ // Hard deadline: a stuck drain must fail this test in seconds, never ride+ // out the runner's 5-minute kill.+ match tokio::time::timeout(std::time::Duration::from_secs(30), run).await {+ Ok(joined) => joined.expect("cron scheduler task"),+ Err(_) => panic!(+ "scheduled run did not drain within 30s (spawn calls: {}, child calls: {}, followups: {})",+ model.spawn_calls.load(std::sync::atomic::Ordering::SeqCst),+ model.child_calls.load(std::sync::atomic::Ordering::SeqCst),+ model.accepted_followups.load(std::sync::atomic::Ordering::SeqCst),+ ),+ }let runs = crate::cron::list_runs(&config, &job.id, 10).expect("read persisted run history");assert_eq!(runs.len(), 1, "scheduler persisted one completed run");assert_eq!(runs[0].status, "ok", "agent job completed successfully");@@ -293,6 +326,7 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settlechild_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),child_started: std::sync::Mutex::new(None),child_release: tokio::sync::Notify::new(),+ child_released: std::sync::atomic::AtomicBool::new(false),});let _model =crate::inference::provider::factory::test_provider_override::install_model(model.clone());@@ -310,7 +344,7 @@ async fn scheduled_agent_timeout_cancels_its_blocked_child_before_history_settleOk(Ok(())) => {}Ok(Err(error)) => panic!("scheduled child exited before its model blocked: {error}"),Err(_) => {- model.child_release.notify_one();+ model.release_child();let _ = tokio::time::timeout(std::time::Duration::from_secs(30), run).await;panic!("scheduled child never reached its blocking model (spawns: {}, accepted followups: {})",@@ -411,6 +445,7 @@ async fn scheduled_cron_child_cannot_run_its_declared_destructive_tool() {child_dangerous_tool_schema_seen: std::sync::atomic::AtomicBool::new(false),child_started: std::sync::Mutex::new(None),child_release: tokio::sync::Notify::new(),+ child_released: std::sync::atomic::AtomicBool::new(false),});let _model =crate::inference::provider::factory::test_provider_override::install_model(model.clone());