Skip to content

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

feat(agent): add subagent registry and wait tool

Steven Enamakel80560defd357
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 b3066fe30a..8eb65f5272 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/registry.rs
@@ -110,7 +110,9 @@ pub(crate) fn register(
) {
if let Some(thread_id) = parent_thread_id.as_deref() {
if crate::agent::orchestration::background_completions::mark_stopped_task_if_thread_stopped(
- thread_id, &task_id,
+ &workspace_dir,
+ thread_id,
+ &task_id,
) {
// Stop landed after the child was spawned but before this registry
// entry existed. The completion is tombstoned above; abort promptly
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_control.rs b/crates/openhuman-core/src/agent/orchestration/subagent_control.rs
index b12d8988d4..c2eb6d3b70 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_control.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_control.rs
@@ -143,12 +143,14 @@ fn handle_subagent_cancel(params: Map<String, Value>) -> ControllerFuture {
// record a completion that flows through the same idle-gated
// delivery and surfaces the cancellation in chat.
background_completions::record_completion(
- meta.parent_session.clone(),
+ &meta.workspace_dir,
+ &meta.parent_session,
&task_id,
meta.agent_id.clone(),
summary,
meta.parent_thread_id.clone(),
- );
+ )
+ .await;
if let Some(subagent_session_id) = meta.subagent_session_id {
let store = subagent_sessions::SubagentSessionStore::new(meta.workspace_dir);
if let Err(err) = subagent_sessions::mark_failed(
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rs
index a820485232..61e17bd32f 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/wait_subagent.rs
@@ -250,6 +250,7 @@ impl WaitSubagentTool {
// still-Running/TimedOut sub-agent has no terminal result yet, so
// a genuinely-later completion must still surface.
crate::agent::orchestration::background_completions::mark_collected(
+ &parent.workspace_dir,
&resolved_task_id,
);
let status = wait_status_payload(
diff --git a/crates/openhuman-core/src/core/runtime/bootstrap.rs b/crates/openhuman-core/src/core/runtime/bootstrap.rs
index 38c064b123..12cdee27a5 100644
--- a/crates/openhuman-core/src/core/runtime/bootstrap.rs
+++ b/crates/openhuman-core/src/core/runtime/bootstrap.rs
@@ -140,6 +140,20 @@ pub(crate) async fn bootstrap_core_runtime(
"[runtime] reconciled {reconciled} orphaned detached sub-agent task(s) on startup"
);
}
+
+ // --- Undelivered background completions ----------------------------
+ // A detached sub-agent that finished in a previous process but whose
+ // result never reached its chat thread is still pending in the durable
+ // completion log (`<workspace>/.openhuman/background_completions.jsonl`).
+ // Schedule its delivery turn through the normal idle-gated path.
+ let redelivering =
+ crate::agent::orchestration::background_delivery::recover_on_boot(&workspace_dir);
+ if redelivering > 0 {
+ log::info!(
+ "[runtime] scheduled redelivery of undelivered background completions for \
+ {redelivering} thread(s) on startup"
+ );
+ }
} else {
log::debug!(
"[boot] agent run-ledger + orchestration task reconciliation SKIPPED — Agent domain disabled"