diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/task/input.rs b/src/crates/assembly/core/src/agentic/tools/implementations/task/input.rs
index caecdc1cbb..e13d4bf782 100644
--- a/src/crates/assembly/core/src/agentic/tools/implementations/task/input.rs
+++ b/src/crates/assembly/core/src/agentic/tools/implementations/task/input.rs
@@ -40,9 +40,18 @@ impl TaskAction {
return None;
}
- let has_agent_id = value.get("agent_id").is_some();
- let has_subagent_type = value.get("subagent_type").is_some();
- let has_fork_context = value.get("fork_context").is_some();
+ let has_agent_id = value
+ .get("agent_id")
+ .and_then(Value::as_str)
+ .is_some_and(|agent_id| !agent_id.trim().is_empty());
+ let has_subagent_type = value
+ .get("subagent_type")
+ .and_then(Value::as_str)
+ .is_some_and(|subagent_type| !subagent_type.trim().is_empty());
+ let has_fork_context = value
+ .get("fork_context")
+ .and_then(Value::as_bool)
+ .unwrap_or(false);
if !has_agent_id && (has_subagent_type || has_fork_context) {
return Some(Self::Spawn);
@@ -143,15 +152,16 @@ impl TaskTool {
TaskAction::Spawn => {
let description = Self::required_string_for_action(input, "description", action)?;
let prompt = Self::required_string_for_action(input, "prompt", action)?;
- if input.get("agent_id").is_some() {
+ if Self::optional_trimmed_string(input, "agent_id")?.is_some() {
return Err(BitFunError::tool(
"agent_id is not allowed when action is spawn".to_string(),
));
}
+ let subagent_type = Self::optional_trimmed_string(input, "subagent_type")?;
let context_mode = Self::context_mode_from_input(input)?;
match context_mode {
SubagentContextMode::Fresh => {
- if input.get("subagent_type").is_none() {
+ if subagent_type.is_none() {
return Err(BitFunError::tool(
"subagent_type is required when action is spawn and fork_context is false or omitted"
.to_string(),
@@ -159,7 +169,7 @@ impl TaskTool {
}
}
SubagentContextMode::Fork => {
- if input.get("subagent_type").is_some() {
+ if subagent_type.is_some() {
return Err(BitFunError::tool(
"subagent_type cannot be combined with fork_context=true when action is spawn; use either subagent_type for a fresh subagent or fork_context=true to inherit the current context."
.to_string(),
@@ -181,7 +191,7 @@ impl TaskTool {
prompt,
context_mode,
target_agent_id: None,
- subagent_type: Self::optional_trimmed_string(input, "subagent_type")?,
+ subagent_type,
model_id,
inherit_parent_model,
timeout_seconds: None,
@@ -321,7 +331,7 @@ impl TaskTool {
fn optional_trimmed_string(input: &Value, field: &str) -> BitFunResult