Skip to content

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

refactor(spawn_async_subagent): extract empty-argument validation helper

Steven Enamakel791f325d16b0
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 d474344bcf..0b3b66aa22 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
@@ -21,15 +21,8 @@ impl SpawnAsyncSubagentTool {
force_fresh,
} = decode_async_spawn_args(&args);
- if agent_id.is_empty() {
- return Ok(ToolResult::error(
- "spawn_async_subagent: `agent_id` is required",
- ));
- }
- if prompt.is_empty() {
- return Ok(ToolResult::error(
- "spawn_async_subagent: `prompt` is required",
- ));
+ 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(
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_results.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_results.rs
index b8ee30300f..1d35f2d253 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_results.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_results.rs
@@ -83,3 +83,17 @@ fn accepted_spawn_result(
fleet,
))
}
+
+fn refuse_empty_spawn_args(agent_id: &str, prompt: &str) -> Option<ToolResult> {
+ if agent_id.is_empty() {
+ return Some(ToolResult::error(
+ "spawn_async_subagent: `agent_id` is required",
+ ));
+ }
+ if prompt.is_empty() {
+ return Some(ToolResult::error(
+ "spawn_async_subagent: `prompt` is required",
+ ));
+ }
+ None
+}