Skip to content

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

fix(workflow-runs): guard failure recording against stale revisions

Steven Enamakel3d08948edf34
diff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs
index a9237b3d36..b2cb240da6 100644
--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs
@@ -41,7 +41,8 @@ fn record_failed_if_current(
| WorkflowRunStatus::Failed
| WorkflowRunStatus::Cancelled
| WorkflowRunStatus::Interrupted
- ) {
+ ) || run.revision != expected_revision
+ {
return;
}
let _ = compare_and_swap_workflow_run_lifecycle(
@@ -58,7 +59,7 @@ fn record_failed_if_current(
started_at: Some(run.started_at),
completed_at: Some(chrono::Utc::now()),
},
- run.revision,
+ expected_revision,
);
}
});
diff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rs
index 204a896ff7..9eb4df5969 100644
--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle_tests.rs
@@ -257,7 +257,10 @@ async fn stale_setup_failure_does_not_overwrite_another_process_lease() {
}
})
.expect("claim workflow lease");
- assert!(matches!(claim, WorkflowLeaseClaim::Acquired(_)));
+ let claimed = match claim {
+ WorkflowLeaseClaim::Acquired(run) => run,
+ other => panic!("expected lease acquisition, got {other:?}"),
+ };
let supervisor = workflow_supervisor().clone();
let handle = supervisor.start_scoped_with_handle(
@@ -282,5 +285,6 @@ async fn stale_setup_failure_does_not_overwrite_another_process_lease() {
.expect("run remains present");
assert_eq!(after.status, WorkflowRunStatus::Running);
assert_eq!(after.lease_owner.as_deref(), Some("other-process"));
+ assert_eq!(after.revision, claimed.revision);
assert_ne!(after.summary.as_deref(), Some("stale setup failure"));
}