Skip to content

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

feat(threads): purge subagent registry entries when threads are deleted

Steven Enamakel415ca28ccccd
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
index d1bc008931..c3ab82510c 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
@@ -124,6 +124,9 @@ pub(crate) fn register(
thread_id
);
}
+ // First spawn in a workspace this process has not scanned: redeliver any
+ // completions a previous process finished there but never delivered.
+ crate::agent::orchestration::background_delivery::recover_on_boot(&workspace_dir);
}
// Typed lifecycle ledger: record the spawn and mirror the child's terminal
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rs
index 60de66efa3..0cacb944f4 100644
--- a/crates/openhuman-core/src/threads/ops/crud.rs
+++ b/crates/openhuman-core/src/threads/ops/crud.rs
@@ -426,7 +426,10 @@ async fn thread_delete_inner(
let cancelled =
crate::agent::orchestration::running_subagents::cancel_for_thread(&request.thread_id);
let discarded =
- crate::agent::orchestration::background_completions::discard_for_thread(&request.thread_id);
+ crate::agent::orchestration::background_completions::discard_for_thread(
+ &dir,
+ &request.thread_id,
+ );
log::debug!(
"[threads] thread_delete thread_id={} cancelled_subagents={} discarded_completions={}",
request.thread_id,
diff --git a/crates/openhuman-core/src/threads/ops/purge.rs b/crates/openhuman-core/src/threads/ops/purge.rs
index d0fa150bad..1649ab959d 100644
--- a/crates/openhuman-core/src/threads/ops/purge.rs
+++ b/crates/openhuman-core/src/threads/ops/purge.rs
@@ -33,9 +33,9 @@ async fn threads_purge_inner(
let cancelled_threads = running_subagents::cancel_all();
let mut discarded = 0;
for thread_id in &cancelled_threads {
- discarded += background_completions::discard_for_thread(thread_id);
+ discarded += background_completions::discard_for_thread(&dir, thread_id);
}
- discarded += background_completions::clear_all();
+ discarded += background_completions::clear_all(&dir);
log::debug!(
"[threads] threads_purge cancelled_threads={} discarded_completions={}",
cancelled_threads.len(),