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
feat(orchestration): track completion owners for background completions
Steven Enamakelddeecf3524c0
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rsindex d5d2ac96e0..a32c99c6fd 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs@@ -247,6 +247,7 @@ pub(crate) fn thread_for_session(session_id: &str) -> Option<String> {/// Record a finished background sub-agent for idle delivery, keyed by its/// parent chat thread. Idempotent on `task_id`.pub(crate) async fn record_completion(+ ctx: &crate::core::runtime::DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -255,6 +256,7 @@ pub(crate) async fn record_completion(parent_thread_id: Option<String>,) {record_outcome(+ ctx,workspace_dir,parent_session,task_id,@@ -275,6 +277,7 @@ pub(crate) async fn record_completion(/// The router drops the record when its task was tombstoned (collected inline,/// stopped) or its thread was cancelled (deleted, stopped).pub(crate) async fn record_outcome(+ ctx: &crate::core::runtime::DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -320,7 +323,7 @@ pub(crate) async fn record_outcome(}note_thread_workspace(&thread_id, workspace_dir);note_session_thread(parent_session, &thread_id);- super::completion_owners::note(&[&task_id, parent_session]); // owner, for off-task delivery+ super::completion_owners::note(ctx, &[&task_id, parent_session]); // owner, for off-task deliverylet record = CompletionRecord::new(task_id.clone(),@@ -380,6 +383,7 @@ pub(crate) async fn record_outcome(/// relay, so the user learns the delegated task errored instead of the turn/// silently finalizing on "Accepted".pub(crate) async fn record_failure(+ ctx: &crate::core::runtime::DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -390,6 +394,7 @@ pub(crate) async fn record_failure(let summary =format!("[SUBAGENT_FAILED] the async sub-agent errored before producing a result: {error}");record_outcome(+ ctx,workspace_dir,parent_session,task_id,@@ -406,6 +411,7 @@ pub(crate) async fn record_failure(/// the framed `[SUBAGENT_NEEDS_INPUT]` notice is delivered back into chat for the/// parent agent to relay to (or answer for) the user.pub(crate) async fn record_awaiting_input(+ ctx: &crate::core::runtime::DispatchCtx,workspace_dir: &Path,parent_session: &str,task_id: impl Into<String>,@@ -424,6 +430,7 @@ pub(crate) async fn record_awaiting_input(checkpointed,);record_outcome(+ ctx,workspace_dir,parent_session,task_id,diff --git a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs b/crates/openhuman-core/src/agent/orchestration/completion_owners.rsindex 474ce11dd7..3aa475c12c 100644--- a/crates/openhuman-core/src/agent/orchestration/completion_owners.rs+++ b/crates/openhuman-core/src/agent/orchestration/completion_owners.rs@@ -43,8 +43,8 @@ fn owners() -> MutexGuard<'static, Owners> {/// Note the calling task's profile as an owner of each id. A no-op outside a/// profile (the desktop, embedded agents).-pub(crate) fn note(ids: &[&str]) {- let Ok(Some(profile)) = crate::core::runtime::current_tenant().map(|t| t.profile) else {+pub(crate) fn note(ctx: &crate::core::runtime::DispatchCtx, ids: &[&str]) {+ let Ok(Some(profile)) = ctx.tenant().map(|t| t.profile) else {return;};note_profile(ids, &profile);diff --git a/crates/openhuman-core/src/agent/orchestration/completion_target.rs b/crates/openhuman-core/src/agent/orchestration/completion_target.rsindex 7f4f0972e5..400c6e6ad0 100644--- a/crates/openhuman-core/src/agent/orchestration/completion_target.rs+++ b/crates/openhuman-core/src/agent/orchestration/completion_target.rs@@ -21,6 +21,8 @@ use super::background_completions::{record_awaiting_input, record_completion, re/// parent key). Built once at spawn so every terminal path records the same way.#[derive(Clone, Debug)]pub(crate) struct CompletionTarget {+ /// The dispatch context the child's completions are recorded under.+ ctx: crate::core::runtime::DispatchCtx,workspace_dir: PathBuf,parent_session: String,parent_thread_id: Option<String>,@@ -28,11 +30,13 @@ pub(crate) struct CompletionTarget {impl CompletionTarget {pub(crate) fn new(+ ctx: crate::core::runtime::DispatchCtx,workspace_dir: PathBuf,parent_session: String,parent_thread_id: Option<String>,) -> Self {Self {+ ctx,workspace_dir,parent_session,parent_thread_id,@@ -42,6 +46,7 @@ impl CompletionTarget {/// Queue a finished result. See [`record_completion`].pub(crate) async fn completed(&self, task_id: &str, agent_id: &str, summary: String) {record_completion(+ &self.ctx,&self.workspace_dir,&self.parent_session,task_id,@@ -55,6 +60,7 @@ impl CompletionTarget {/// Queue a failure. See [`record_failure`].pub(crate) async fn failed(&self, task_id: &str, agent_id: &str, error: &str) {record_failure(+ &self.ctx,&self.workspace_dir,&self.parent_session,task_id,@@ -74,6 +80,7 @@ impl CompletionTarget {checkpointed: bool,) {record_awaiting_input(+ &self.ctx,&self.workspace_dir,&self.parent_session,task_id,diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_control.rs b/crates/openhuman-core/src/agent/orchestration/subagent_control.rsindex 124dc2500c..aa57018cf6 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_control.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_control.rs@@ -144,6 +144,7 @@ fn handle_subagent_cancel(ctx: DispatchCtx, params: Map<String, Value>) -> Contr// record a completion that flows through the same idle-gated// delivery and surfaces the cancellation in chat.background_completions::record_completion(+ &ctx,&meta.workspace_dir,&meta.parent_session,&task_id,