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
fix(cron): pass runtime dispatch context to run now
Steven Enamakel798294684504
diff --git a/crates/openhuman-embed/src/cron.rs b/crates/openhuman-embed/src/cron.rsindex f754fa460c..5ab480534c 100644--- a/crates/openhuman-embed/src/cron.rs+++ b/crates/openhuman-embed/src/cron.rs@@ -348,11 +348,16 @@ pub enum CronError {/// [`Runtime::cron`](crate::Runtime::cron).pub struct Cron<'a> {config: &'a Config,+ /// The runtime's own context: what a Run Now executes and delivers under.+ dispatch: openhuman_core::core::runtime::DispatchCtx,}impl<'a> Cron<'a> {- pub(crate) fn new(config: &'a Config) -> Self {- Self { config }+ pub(crate) fn new(+ config: &'a Config,+ dispatch: openhuman_core::core::runtime::DispatchCtx,+ ) -> Self {+ Self { config, dispatch }}fn enabled(&self) -> Result<(), CronError> {@@ -458,7 +463,7 @@ impl<'a> Cron<'a> {.find(name)?.ok_or_else(|| CronError::NotFound(name.to_string()))?;log::debug!("[embed][cron] run_now name={name} id={}", job.id);- let (success, output) = openhuman_core::cron::ops::run_job_now(self.config, &job.id)+ let (success, output) = openhuman_core::cron::ops::run_job_now(&self.dispatch, self.config, &job.id).await.map_err(CronError::Run)?;Ok(JobRun { success, output })diff --git a/crates/openhuman-embed/src/runtime/mod.rs b/crates/openhuman-embed/src/runtime/mod.rsindex 806c138546..e89a0246c3 100644--- a/crates/openhuman-embed/src/runtime/mod.rs+++ b/crates/openhuman-embed/src/runtime/mod.rs@@ -386,7 +386,10 @@ impl Runtime {/// The runtime's scheduled jobs. See [`crate::cron`].pub fn cron(&self) -> crate::cron::Cron<'_> {- crate::cron::Cron::new(&self.base_config)+ crate::cron::Cron::new(+ &self.base_config,+ openhuman_core::core::runtime::DispatchCtx::new(self.core_runtime().context().clone()),+ )}/// Run `handler` whenever system job `name` comes due (seediff --git a/tests/support/cron_policy_failure.rs b/tests/support/cron_policy_failure.rsindex 69dc7f1270..26915d329f 100644--- a/tests/support/cron_policy_failure.rs+++ b/tests/support/cron_policy_failure.rs@@ -355,8 +355,8 @@ pub(super) async fn policy_reads_refuse_execution_without_consuming_a_slot(case:let scheduled_calls = calls.load(Ordering::SeqCst);let (manual, queued, tool) = CoreContext::scope(Arc::clone(&alpha), async {assert!(policy::get_policy(&config, &job.id).is_err());- let manual = cron::ops::run_job_now(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await;- let queued = cron::ops::cron_run(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await;+ let manual = cron::ops::run_job_now(&openhuman::core::runtime::DispatchCtx::ambient(), &config, &job.id).await;+ let queued = cron::ops::cron_run(&openhuman::core::runtime::DispatchCtx::ambient(), &config, &job.id).await;let tool = cron::tools::CronRunTool::new(Arc::new(config.clone())).execute(json!({"job_id": job.id})).await@@ -424,7 +424,7 @@ pub(super) async fn policy_reads_refuse_execution_without_consuming_a_slot(case:policy::get_policy(&config, &job.id).unwrap(),JobPolicy::default());- assert!(cron::ops::run_job_now(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap().0);+ assert!(cron::ops::run_job_now(&openhuman::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.unwrap().0);}).await;assert_eq!(@@ -482,7 +482,7 @@ pub(super) async fn malformed_policy_rows_refuse_execution(case: Case) {policy::get_policy(&config, &job.id).is_err(),"a malformed existing row became a usable policy");- let refused = cron::ops::run_job_now(&crate::core::runtime::DispatchCtx::ambient(), &config, &job.id)+ let refused = cron::ops::run_job_now(&openhuman::core::runtime::DispatchCtx::ambient(), &config, &job.id).await.expect_err("a malformed policy must refuse Run now");assert!(!refused.contains("private-payload"));