agent run: queue targeted runs to daemon, one task per node

--target and --query now queue individual daemon tasks instead of
running sequentially in the CLI. Each node gets its own choir task
with LLM resource locking. Falls back to local execution if daemon
isn't running.

RPC extended: "run-agent linker 1 target:KEY" spawns a targeted task.
This commit is contained in:
ProofOfConcept 2026-03-17 01:24:54 -04:00
parent 83a027d8be
commit 7fc1270d6f
2 changed files with 69 additions and 5 deletions

View file

@ -28,10 +28,29 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
};
if !resolved_targets.is_empty() {
// Run agent once with all targets as seeds
crate::agents::knowledge::run_one_agent_with_keys(
&mut store, agent, &resolved_targets, count, "test", &log, debug,
)?;
// Queue one daemon task per target node
let mut queued = 0;
for key in &resolved_targets {
let cmd = format!("run-agent {} 1 target:{}", agent, key);
match crate::agents::daemon::send_rpc_pub(&cmd) {
Some(_) => queued += 1,
None => {
eprintln!("Daemon not running — falling back to local execution");
// Local fallback: run sequentially
for (i, key) in resolved_targets.iter().enumerate() {
eprintln!("[{}] [{}/{}] {}", agent, i + 1, resolved_targets.len(), key);
if i > 0 { store = store::Store::load()?; }
if let Err(e) = crate::agents::knowledge::run_one_agent_with_keys(
&mut store, agent, &[key.clone()], count, "test", &log, debug,
) {
eprintln!("[{}] ERROR on {}: {}", agent, key, e);
}
}
return Ok(());
}
}
}
eprintln!("[{}] queued {} tasks to daemon", agent, queued);
} else if debug {
crate::agents::knowledge::run_one_agent(
&mut store, agent, count, "test", &log, true,