20 lines
676 B
Rust
20 lines
676 B
Rust
use tokio::sync::mpsc;
|
|||
|
|
use super::context::SubagentContext;
|
||
|
|
use super::event::SubagentEvent;
|
||
|
|
|
||
|
|
pub const MAX_AGENT_STEPS: usize = 25;
|
||
|
|
|
||
|
|
pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> anyhow::Result<String> {
|
||
|
|
let mut output = String::new();
|
||
|
|
for step in 0..ctx.max_steps.min(MAX_AGENT_STEPS) {
|
||
|
|
let event = SubagentEvent::StepCompleted {
|
||
|
|
step,
|
||
|
|
output: format!("step {} completed", step),
|
||
|
|
};
|
||
|
|
let _ = tx.blocking_send(event);
|
||
|
|
output.push_str(&format!("step {} completed\n", step));
|
||
|
|
}
|
||
|
|
let _ = tx.blocking_send(SubagentEvent::Completed { output: output.clone() });
|
||
|
|
Ok(output)
|
||
|
|
}
|