Skip to content

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

refactor(spawn_subagent): extract preflight logic into included module

Steven Enamakelac7bddd9aa4c
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
index 17a36bfaed..88c2a7e242 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
@@ -11,25 +11,7 @@ impl SpawnSubagentTool {
>,
>,
) -> anyhow::Result<ToolResult> {
- let dispatch = run_context.dispatch_ctx();
- let AsyncSpawnArgs {
- agent_id,
- mut prompt,
- context,
- model_override,
- task_title,
- task_key,
- force_fresh,
- } = decode_async_spawn_args(&args);
-
- if let Some(refusal) = refuse_empty_spawn_args(&agent_id, &prompt) {
- return Ok(refusal);
- }
- let Some(detached_parent) = detached_parent else {
- return Ok(ToolResult::error(
- "spawn_subagent requires a live harness run context.",
- ));
- };
+ include!("spawn_subagent_preflight.rs");
let parent = match run_context.parent.clone() {
Some(parent) => parent,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_preflight.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_preflight.rs
new file mode 100644
index 0000000000..70d95b5a84
--- /dev/null
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_preflight.rs
@@ -0,0 +1,19 @@
+let dispatch = run_context.dispatch_ctx();
+let AsyncSpawnArgs {
+ agent_id,
+ mut prompt,
+ context,
+ model_override,
+ task_title,
+ task_key,
+ force_fresh,
+} = decode_async_spawn_args(&args);
+
+if let Some(refusal) = refuse_empty_spawn_args(&agent_id, &prompt) {
+ return Ok(refusal);
+}
+let Some(detached_parent) = detached_parent else {
+ return Ok(ToolResult::error(
+ "spawn_subagent requires a live harness run context.",
+ ));
+};