Skip to content

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

refactor(agent): route subagent completion recording through completion_target

Steven Enamakel298c747aea44
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
index 9085be6652..c196991d95 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
@@ -485,14 +485,9 @@ impl SpawnAsyncSubagentTool {
// Queue the finished result for idle-gated, batched
// delivery back into the parent chat (the session
// runtime drains this when the session is next idle).
- crate::agent::orchestration::background_completions::record_completion(
- &background_workspace_dir,
-&background_parent_session,
- outcome.task_id.clone(),
- outcome.agent_id.clone(),
- delivery_summary,
- background_parent_thread_id.clone(),
- ).await;
+ completion_target
+ .completed(&outcome.task_id, &outcome.agent_id, delivery_summary)
+ .await;
if emit_lifecycle_effects {
crate::agent::orchestration::subagent_events::publish_subagent_completed(
background_parent_session,
@@ -564,14 +559,9 @@ impl SpawnAsyncSubagentTool {
&outcome.final_history,
framed,
);
- crate::agent::orchestration::background_completions::record_completion(
- &background_workspace_dir,
-&background_parent_session,
- outcome.task_id.clone(),
- outcome.agent_id.clone(),
- framed,
- background_parent_thread_id.clone(),
- ).await;
+ completion_target
+ .completed(&outcome.task_id, &outcome.agent_id, framed)
+ .await;
if emit_lifecycle_effects {
crate::agent::orchestration::subagent_events::publish_subagent_completed(
background_parent_session,
@@ -624,14 +614,9 @@ impl SpawnAsyncSubagentTool {
let _ = status_tx.send(DetachedSubagentStatus::Failed {
error: error.clone(),
});
- crate::agent::orchestration::background_completions::record_failure(
- &background_workspace_dir,
-&background_parent_session,
- outcome.task_id.clone(),
- outcome.agent_id.clone(),
- &error,
- background_parent_thread_id.clone(),
- ).await;
+ completion_target
+ .failed(&outcome.task_id, &outcome.agent_id, &error)
+ .await;
if emit_lifecycle_effects {
crate::agent::orchestration::subagent_events::publish_subagent_failed(
background_parent_session,
@@ -676,15 +661,14 @@ impl SpawnAsyncSubagentTool {
// parent chat learns the delegated task needs input,
// instead of finalizing silently on "Accepted". Rides the
// same idle-gated background_delivery path as a success.
- crate::agent::orchestration::background_completions::record_awaiting_input(
- &background_workspace_dir,
-&background_parent_session,
- outcome.task_id.clone(),
- outcome.agent_id.clone(),
- question,
- checkpoint.is_some(),
- background_parent_thread_id.clone(),
- ).await;
+ completion_target
+ .awaiting_input(
+ &outcome.task_id,
+ &outcome.agent_id,
+ question,
+ checkpoint.is_some(),
+ )
+ .await;
if emit_lifecycle_effects {
crate::agent::orchestration::subagent_events::publish_subagent_awaiting_user(
background_parent_session,
@@ -731,14 +715,9 @@ impl SpawnAsyncSubagentTool {
// turn finalized on "Accepted" and the failure was lost.
// Queue a framed failure notice so background_delivery
// surfaces it as a follow-up chat turn.
- crate::agent::orchestration::background_completions::record_failure(
- &background_workspace_dir,
-&background_parent_session,
- background_task_id.clone(),
- background_agent_id.clone(),
- &error,
- background_parent_thread_id.clone(),
- ).await;
+ completion_target
+ .failed(&background_task_id, &background_agent_id, &error)
+ .await;
crate::agent::orchestration::subagent_events::publish_subagent_failed(
background_parent_session,
background_task_id.clone(),