Skip to content

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

chore: files changed crates/openhuman-core/src/cron/ops.rs,crates/openhuman-core/src/cron/scheduler/

Steven Enamakel8fe99b53bd6d
diff --git a/crates/openhuman-core/src/cron/ops.rs b/crates/openhuman-core/src/cron/ops.rs
index 76f24488ce..2e51d81943 100644
--- a/crates/openhuman-core/src/cron/ops.rs
+++ b/crates/openhuman-core/src/cron/ops.rs
@@ -313,6 +313,7 @@ async fn run_and_record(
Some(delivery_status),
);
let _ = cron::record_last_run(config, &job.id, finished_at, success, &output);
+ crate::cron::scheduler::run_delivery::publish_completion(ctx, job, success, &output);
(success, output)
}
diff --git a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs b/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
index 55af8dead5..65a8939299 100644
--- a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
@@ -43,29 +43,41 @@ pub(crate) async fn deliver(
// The job ran as its agent (when it had one); a one-shot job
// is deleted once the run completes, so subscribers learn the
// owner here, not from the store.
- crate::cron::completion_owner::note(&ctx, &job.id);
- BUS.publish(DomainEvent::CronJobCompleted {
- job_id: job.id.clone(),
- success,
- output: crate::util::truncate_with_ellipsis(&attempt.output, 512),
- });
binding.finish_triggered_run(run_id);
- BUS.publish(DomainEvent::HealthChanged {
- component: "scheduler".to_string(),
- healthy: success,
- message: (!success).then(|| {
- if attempt.output.is_empty() {
- format!("job {} failed", job.id)
- } else {
- crate::util::truncate_with_ellipsis(&attempt.output, 256)
- }
- }),
- });
+ publish_completion(&ctx, job, success, &attempt.output);
result
})
.await
}
+/// Publish the final status shared by scheduled callbacks, Run Now, and the
+/// non-delivering `cron_run` tool. Callers decide delivery and persistence
+/// before projecting this event.
+pub(crate) fn publish_completion(
+ ctx: &crate::core::runtime::DispatchCtx,
+ job: &CronJob,
+ success: bool,
+ output: &str,
+) {
+ crate::cron::completion_owner::note(ctx, &job.id);
+ BUS.publish(DomainEvent::CronJobCompleted {
+ job_id: job.id.clone(),
+ success,
+ output: crate::util::truncate_with_ellipsis(output, 512),
+ });
+ BUS.publish(DomainEvent::HealthChanged {
+ component: "scheduler".to_string(),
+ healthy: success,
+ message: (!success).then(|| {
+ if output.is_empty() {
+ format!("job {} failed", job.id)
+ } else {
+ crate::util::truncate_with_ellipsis(output, 256)
+ }
+ }),
+ });
+}
+
/// A `flow` row standing in for a trigger whose stored row cannot be read (it
/// was removed between the claim and the tick). The handler needs only the
/// bound flow id, which is the row's `command`.
diff --git a/crates/openhuman-core/src/cron/tools/run.rs b/crates/openhuman-core/src/cron/tools/run.rs
index 7aa8530d81..d156627ab2 100644
--- a/crates/openhuman-core/src/cron/tools/run.rs
+++ b/crates/openhuman-core/src/cron/tools/run.rs
@@ -131,6 +131,12 @@ impl Tool for CronRunTool {
Some(delivery_status),
);
let _ = cron::record_last_run(&self.config, &job.id, finished_at, success, &output);
+ crate::cron::scheduler::run_delivery::publish_completion(
+ &dispatch,
+ &job,
+ success,
+ &output,
+ );
let payload = json!({
"job_id": job.id,