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
refactor(orchestration): clean up background completions logic
Steven Enamakelf0da0bb351c3
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rsindex 6a13551ef3..c420374b92 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs@@ -304,7 +304,6 @@ pub(crate) async fn record_outcome_with_parent_epoch(}}-async fn record_completion_record(ctx: &DispatchCtx,workspace_dir: &Path,diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_migration_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_migration_tests.rsindex 0fb3d99b51..59edaf468b 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions_migration_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_migration_tests.rs@@ -387,7 +387,13 @@ async fn transient_parent_admission_failure_does_not_permanently_delete_thread()"retryable-parent","accepted-child",));- record_admitted(w, "retryable-session", "accepted-child", "recovered", "retryable-parent");+ record_admitted(+ w,+ "retryable-session",+ "accepted-child",+ "recovered",+ "retryable-parent",+ );assert_eq!(pending_ids(w, "retryable-parent"), ["accepted-child"]);}diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rsindex 1891396924..186da98776 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs@@ -348,7 +348,7 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {worker_thread_id: None,task_id: "task-cold-1".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rsindex d3cc01682b..210272175f 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_tests.rs@@ -55,7 +55,7 @@ fn compatible_session_reuses_and_incompatible_shape_spawns_new() {worker_thread_id: Some("worker-1".into()),task_id: "sub-1".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,};let session = upsert_running(&store, upsert, None).unwrap();mark_finished(@@ -90,7 +90,7 @@ fn stale_completion_cannot_overwrite_reused_or_closed_session() {worker_thread_id: None,task_id: "first-task".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)@@ -104,7 +104,7 @@ fn stale_completion_cannot_overwrite_reused_or_closed_session() {worker_thread_id: None,task_id: "second-task".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},Some(&first),)@@ -167,7 +167,7 @@ fn driver_task_cancel_reports_legacy_failure_and_refuses_ambiguous_ids() {worker_thread_id: None,task_id: "finished-failed".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)@@ -198,7 +198,7 @@ fn driver_task_cancel_reports_legacy_failure_and_refuses_ambiguous_ids() {thread_id: Some("thread-a".into()),task_id: "same-public-id".into(),}),- parent_epoch: None,+ parent_epoch: None,},None,)@@ -217,7 +217,7 @@ fn driver_task_cancel_reports_legacy_failure_and_refuses_ambiguous_ids() {thread_id: Some("thread-a".into()),task_id: "same-public-id".into(),}),- parent_epoch: None,+ parent_epoch: None,},None,)@@ -276,7 +276,7 @@ fn cancellation_reason_is_written_only_for_the_observed_full_lifecycle() {worker_thread_id: None,task_id: key.task_id.clone(),lifecycle_key: Some(key.clone()),- parent_epoch: None,+ parent_epoch: None,},None,)@@ -391,7 +391,7 @@ fn stale_close_and_reuse_snapshots_cannot_change_a_newer_lifecycle() {worker_thread_id: None,task_id: "same-public-task".into(),lifecycle_key: Some(first_key.clone()),- parent_epoch: None,+ parent_epoch: None,},None,)@@ -405,7 +405,7 @@ fn stale_close_and_reuse_snapshots_cannot_change_a_newer_lifecycle() {worker_thread_id: None,task_id: "same-public-task".into(),lifecycle_key: Some(second_key.clone()),- parent_epoch: None,+ parent_epoch: None,},Some(&first),)@@ -436,7 +436,7 @@ fn stale_close_and_reuse_snapshots_cannot_change_a_newer_lifecycle() {worker_thread_id: None,task_id: "stale-task".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},Some(&first),)@@ -459,7 +459,7 @@ fn stale_close_and_reuse_snapshots_cannot_change_a_newer_lifecycle() {worker_thread_id: None,task_id: "late-task".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},Some(&second),)@@ -487,7 +487,7 @@ fn upsert_persists_the_full_lifecycle_key_without_collapsing_to_task_id() {worker_thread_id: None,task_id: "sub-1".into(),lifecycle_key: Some(key.clone()),- parent_epoch: None,+ parent_epoch: None,},None,)@@ -533,7 +533,7 @@ fn closed_session_is_not_reusable() {worker_thread_id: None,task_id: "sub-1".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)@@ -556,7 +556,7 @@ fn list_for_parent_without_thread_id_does_not_filter_by_thread() {worker_thread_id: None,task_id: "sub-1".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)@@ -573,7 +573,7 @@ fn list_for_parent_without_thread_id_does_not_filter_by_thread() {worker_thread_id: None,task_id: "sub-2".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rsindex de44a972df..e08c1efbc1 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs@@ -67,7 +67,7 @@ async fn late_registration_refusal_aborts_the_worker_and_settles_its_durable_sesworker_thread_id: None,task_id: "late-refusal-task".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rsindex abc8f2b27e..396022aded 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs@@ -235,7 +235,7 @@ async fn cancelling_a_paused_driver_through_rpc_settles_once_with_its_reason() {worker_thread_id: None,task_id: task_id.clone(),lifecycle_key: Some(lifecycle_key),- parent_epoch: None,+ parent_epoch: None,},None,)diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rsindex 7afbf4eb34..e411099c49 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs@@ -330,7 +330,7 @@ async fn continue_subagent_resumes_idle_durable_session_e2e() {worker_thread_id: None,task_id: "sub-earlier-task".into(),lifecycle_key: None,- parent_epoch: None,+ parent_epoch: None,},None,)diff --git a/crates/openhuman-core/src/agent_runs/subagent_control.rs b/crates/openhuman-core/src/agent_runs/subagent_control.rsindex 87c4a5a935..614072a330 100644--- a/crates/openhuman-core/src/agent_runs/subagent_control.rs+++ b/crates/openhuman-core/src/agent_runs/subagent_control.rs@@ -239,7 +239,10 @@ async fn settle_paused_driver_cancel(Some(reason) => format!("cancelled by user. Reason: {reason}"),None => "cancelled by user".to_string(),};- let parent_epoch = paused.parent_thread_id.as_ref().map(|_| parent_epoch.unwrap_or(0));+ let parent_epoch = paused+ .parent_thread_id+ .as_ref()+ .map(|_| parent_epoch.unwrap_or(0));background_completions::record_outcome_with_parent_epoch(ctx,&paused.workspace_dir,