Summary
Add a task tool that spawns clemini subprocesses to handle delegated work, similar to Claude Code's Task tool.
Core Concept
Task is simple subprocess spawning:
- Spawn subprocess with prompt →
cargo run -- -p "do X"
- Capture output → stdout/stderr
- Return result → JSON response
Building Blocks Already Available
Implementation
// Pseudocode
fn task_tool(prompt: &str, background: bool) -> Result<Value> {
let child = Command::new("cargo")
.args(["run", "--", "-p", prompt])
.spawn()?;
if background {
// Store handle, return task_id for later retrieval
Ok(json!({"task_id": "abc123", "status": "running"}))
} else {
// Wait and return output
let output = child.wait_with_output()?;
Ok(json!({"output": String::from_utf8_lossy(&output.stdout)}))
}
}
Tool Schema
struct TaskTool {
/// The prompt/task to give to the subagent
prompt: String,
/// Run in background (default: false)
/// If true, returns task_id immediately
/// If false, waits for completion and returns output
#[serde(default)]
background: bool,
/// Optional: specific subagent type (future: explore, plan, etc.)
#[serde(default)]
subagent_type: Option<String>,
}
Return Values
Foreground (background=false):
{
"status": "completed",
"output": "Task result here...",
"exit_code": 0
}
Background (background=true):
{
"task_id": "task_abc123",
"status": "running"
}
Task Management
Reuse existing background shell infrastructure:
- Store task handles in same registry as background bash
KillShell can kill tasks
- Add
TaskOutput tool to retrieve results (or extend existing mechanism)
No Architectural Changes Needed
This is pure process management. #59 (streaming-first) is an optimization for complex multi-agent workflows with real-time streaming - not a prerequisite.
Related
Summary
Add a
tasktool that spawns clemini subprocesses to handle delegated work, similar to Claude Code's Task tool.Core Concept
Task is simple subprocess spawning:
cargo run -- -p "do X"Building Blocks Already Available
run_in_background(Bash tool: add run_in_background and description options #13, bash: Add run_in_background parameter #69, Add KillShell tool for background task management #70 ✅)KillShellfor process managementstd::processImplementation
Tool Schema
Return Values
Foreground (background=false):
{ "status": "completed", "output": "Task result here...", "exit_code": 0 }Background (background=true):
{ "task_id": "task_abc123", "status": "running" }Task Management
Reuse existing background shell infrastructure:
KillShellcan kill tasksTaskOutputtool to retrieve results (or extend existing mechanism)No Architectural Changes Needed
This is pure process management. #59 (streaming-first) is an optimization for complex multi-agent workflows with real-time streaming - not a prerequisite.
Related