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): extract completion target into its own module
Steven Enamakelb6b340df2bf4
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rsindex aba9284000..1e969ee517 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs@@ -34,6 +34,9 @@ use tinyagents_tasks::{use super::completion_notice::BackgroundCompletionFormatter;pub(crate) use super::completion_notice::{BackgroundAgentOutcome, AWAITING_INPUT_LABEL};+pub(crate) use super::completion_target::CompletionTarget;+#[cfg(test)]+pub(crate) use super::completion_target::TestWorkspace;/// How long a settled record (delivered / gave up / tombstoned) is kept before/// compaction drops it. Dropping a settled record also drops its dedupe and its@@ -406,76 +409,6 @@ pub(crate) async fn release_all() -> usize {released}-/// Where one detached child's completion lands: its workspace (which router),-/// the parent session (the idle gate) and the parent chat thread (the router's-/// parent key). Built once at spawn so every terminal path records the same way.-#[derive(Clone, Debug)]-pub(crate) struct CompletionTarget {- workspace_dir: PathBuf,- parent_session: String,- parent_thread_id: Option<String>,-}--impl CompletionTarget {- pub(crate) fn new(- workspace_dir: PathBuf,- parent_session: String,- parent_thread_id: Option<String>,- ) -> Self {- Self {- workspace_dir,- parent_session,- parent_thread_id,- }- }-- /// Queue a finished result. See [`record_completion`].- pub(crate) async fn completed(&self, task_id: &str, agent_id: &str, summary: String) {- record_completion(- &self.workspace_dir,- &self.parent_session,- task_id,- agent_id,- summary,- self.parent_thread_id.clone(),- )- .await;- }-- /// Queue a failure. See [`record_failure`].- pub(crate) async fn failed(&self, task_id: &str, agent_id: &str, error: &str) {- record_failure(- &self.workspace_dir,- &self.parent_session,- task_id,- agent_id,- error,- self.parent_thread_id.clone(),- )- .await;- }-- /// Queue an awaiting-input pause. See [`record_awaiting_input`].- pub(crate) async fn awaiting_input(- &self,- task_id: &str,- agent_id: &str,- question: &str,- checkpointed: bool,- ) {- record_awaiting_input(- &self.workspace_dir,- &self.parent_session,- task_id,- agent_id,- question,- checkpointed,- self.parent_thread_id.clone(),- )- .await;- }-}-/// Undelivered completions for `thread_id`, oldest first (read-only; includes/// records an in-flight delivery currently holds).pub(crate) fn pending_for(workspace_dir: &Path, thread_id: &str) -> Vec<CompletionRecord> {@@ -749,29 +682,6 @@ pub(crate) fn forget_workspace_for_test(workspace_dir: &Path) {st.session_order.clear();}-/// A temporary workspace that forgets its router when dropped, so the-/// process-wide registry does not accumulate entries for deleted directories.-#[cfg(test)]-pub(crate) struct TestWorkspace(tempfile::TempDir);--#[cfg(test)]-impl TestWorkspace {- pub(crate) fn new() -> Self {- Self(tempfile::tempdir().expect("tempdir"))- }-- pub(crate) fn path(&self) -> &Path {- self.0.path()- }-}--#[cfg(test)]-impl Drop for TestWorkspace {- fn drop(&mut self) {- forget_workspace_for_test(self.0.path());- }-}-#[cfg(test)]#[path = "background_completions_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/agent/orchestration/completion_target.rs b/crates/openhuman-core/src/agent/orchestration/completion_target.rsnew file mode 100644index 0000000000..45bca42fd6--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/completion_target.rs@@ -0,0 +1,102 @@+//! The per-spawn handle a detached sub-agent records its completion through.+//!+//! Built once at spawn so every terminal path (completed, incomplete, failed,+//! awaiting input) records the same way, in the same workspace router, for the+//! same parent thread. The queue itself is [`super::background_completions`].++use std::path::{Path, PathBuf};++use super::background_completions::{record_awaiting_input, record_completion, record_failure};++/// Where one detached child's completion lands: its workspace (which router),+/// the parent session (the idle gate) and the parent chat thread (the router's+/// parent key). Built once at spawn so every terminal path records the same way.+#[derive(Clone, Debug)]+pub(crate) struct CompletionTarget {+ workspace_dir: PathBuf,+ parent_session: String,+ parent_thread_id: Option<String>,+}++impl CompletionTarget {+ pub(crate) fn new(+ workspace_dir: PathBuf,+ parent_session: String,+ parent_thread_id: Option<String>,+ ) -> Self {+ Self {+ workspace_dir,+ parent_session,+ parent_thread_id,+ }+ }++ /// Queue a finished result. See [`record_completion`].+ pub(crate) async fn completed(&self, task_id: &str, agent_id: &str, summary: String) {+ record_completion(+ &self.workspace_dir,+ &self.parent_session,+ task_id,+ agent_id,+ summary,+ self.parent_thread_id.clone(),+ )+ .await;+ }++ /// Queue a failure. See [`record_failure`].+ pub(crate) async fn failed(&self, task_id: &str, agent_id: &str, error: &str) {+ record_failure(+ &self.workspace_dir,+ &self.parent_session,+ task_id,+ agent_id,+ error,+ self.parent_thread_id.clone(),+ )+ .await;+ }++ /// Queue an awaiting-input pause. See [`record_awaiting_input`].+ pub(crate) async fn awaiting_input(+ &self,+ task_id: &str,+ agent_id: &str,+ question: &str,+ checkpointed: bool,+ ) {+ record_awaiting_input(+ &self.workspace_dir,+ &self.parent_session,+ task_id,+ agent_id,+ question,+ checkpointed,+ self.parent_thread_id.clone(),+ )+ .await;+ }+}++/// A temporary workspace that forgets its router when dropped, so the+/// process-wide registry does not accumulate entries for deleted directories.+#[cfg(test)]+pub(crate) struct TestWorkspace(tempfile::TempDir);++#[cfg(test)]+impl TestWorkspace {+ pub(crate) fn new() -> Self {+ Self(tempfile::tempdir().expect("tempdir"))+ }++ pub(crate) fn path(&self) -> &Path {+ self.0.path()+ }+}++#[cfg(test)]+impl Drop for TestWorkspace {+ fn drop(&mut self) {+ super::background_completions::forget_workspace_for_test(self.0.path());+ }+}diff --git a/crates/openhuman-core/src/agent/orchestration/mod.rs b/crates/openhuman-core/src/agent/orchestration/mod.rsindex 071bdc03d2..a86758bc04 100644--- a/crates/openhuman-core/src/agent/orchestration/mod.rs+++ b/crates/openhuman-core/src/agent/orchestration/mod.rs@@ -20,6 +20,7 @@ pub(crate) mod background_completions;pub(crate) mod background_delivery;pub mod command_center;pub(crate) mod completion_notice;+pub(crate) mod completion_target;pub(crate) mod delegation;pub(crate) mod fleet_tools;mod ops;