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(threads): persist deleted-parent marker when thread deletion fails
Steven Enamakelcbd1c3f4449f
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rsindex 733df0fbd5..f5701695c9 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs@@ -27,8 +27,8 @@ mod store_adapter;mod thread_index;use parent_lifecycle::is_marked_deleted;pub(crate) use parent_lifecycle::{- clear_all, discard_for_thread, discard_pending_for_thread, finish_stop_for_thread,- mark_stopped_task_if_thread_stopped, resume_stopped_thread,+ clear_all, delete_parent_for_thread, discard_for_thread, discard_pending_for_thread,+ finish_stop_for_thread, mark_stopped_task_if_thread_stopped, resume_stopped_thread,};pub(crate) use store_adapter::router_for_workspace_ctx;pub(super) use store_adapter::{diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions/parent_lifecycle.rs b/crates/openhuman-core/src/agent/orchestration/background_completions/parent_lifecycle.rsindex a09200843e..a87e0f09c0 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions/parent_lifecycle.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions/parent_lifecycle.rs@@ -46,6 +46,33 @@ pub(crate) fn discard_for_thread(removed}+/// Durably close a deleted parent and withdraw queued results, even when its+/// child sweep reported an unresolved task. The conversation row is already+/// gone, so late results must remain rejected after a process restart.+pub(crate) fn delete_parent_for_thread(+ ctx: &DispatchCtx,+ workspace_dir: &Path,+ thread_id: &str,+) -> Result<usize, String> {+ let thread_key = key(ctx, thread_id);+ {+ let mut st = state();+ st.deleted_threads.insert(thread_key.clone());+ st.stopped_threads.remove(&thread_key);+ st.thread_workspaces+ .insert(thread_key, workspace_dir.to_path_buf());+ }+ let entry = entry_for_ctx(ctx, workspace_dir);+ let removed = entry+ .router+ .delete_parent(thread_id)+ .map_err(|error| format!("failed to persist deleted-parent marker: {error}"))?;+ log::debug!(+ "[background_completions] delete_parent_for_thread thread_id={thread_id} removed={removed}"+ );+ Ok(removed)+}+/// Task id used by the legacy durable "this thread was deleted" marker./// Current deletions use the router's `ParentDeleted` lifecycle state; this/// marker remains readable for rows written by older host versions.diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rsindex 13365276ed..1a31316149 100644--- a/crates/openhuman-core/src/threads/ops/crud.rs+++ b/crates/openhuman-core/src/threads/ops/crud.rs@@ -505,9 +505,23 @@ async fn thread_delete_inner(// completion in the gap between the two calls, then discard anything already// queued for delivery. Both target a thread that's being deleted, so there's// nowhere left to deliver to — abort + cleanup is the whole behavior.- let cancelled_legacy =- crate::agent::orchestration::running_subagents::cancel_for_thread(&ctx, &request.thread_id)- .await?;+ let cancelled_legacy = match crate::agent::orchestration::running_subagents::cancel_for_thread(+ &ctx,+ &request.thread_id,+ )+ .await+ {+ Ok(cancelled) => cancelled,+ Err(error) => {+ crate::agent::orchestration::background_completions::delete_parent_for_thread(+ &ctx,+ &dir,+ &request.thread_id,+ )+ .map_err(|close_error| format!("{error}; {close_error}"))?;+ return Err(error);+ }+ };let jobs = crate::core::runtime::slot_for::<tinyagents_harness_tools::subagents::SubAgentJobRegistry,>(&ctx);@@ -520,11 +534,11 @@ async fn thread_delete_inner().len();let cancelled = cancelled_legacy + cancelled_driver;- let discarded = crate::agent::orchestration::background_completions::discard_for_thread(+ let discarded = crate::agent::orchestration::background_completions::delete_parent_for_thread(&ctx,&dir,&request.thread_id,- );+ )?;log::debug!("[threads] thread_delete thread_id={} cancelled_subagents={} discarded_completions={}",request.thread_id,