Upgrade workspace to edition 2024, add --local flag to agent run
Edition 2024 changes: - gen is reserved: rename variable in query/engine.rs - set_var is unsafe: wrap in unsafe block in cli/agent.rs - match ergonomics: add explicit & in spectral.rs filter closure New --local flag for `poc-memory agent run` bypasses the daemon and runs the agent directly in-process. Useful for testing agent prompt changes without waiting in the daemon queue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c153daacd5
commit
0a62832fe3
7 changed files with 1515 additions and 56 deletions
|
|
@ -3,9 +3,10 @@
|
|||
use crate::store;
|
||||
use crate::agents::llm;
|
||||
|
||||
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, debug: bool) -> Result<(), String> {
|
||||
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, debug: bool, local: bool) -> Result<(), String> {
|
||||
if dry_run {
|
||||
std::env::set_var("POC_MEMORY_DRY_RUN", "1");
|
||||
// SAFETY: single-threaded at this point (CLI startup, before any agent work)
|
||||
unsafe { std::env::set_var("POC_MEMORY_DRY_RUN", "1"); }
|
||||
}
|
||||
let mut store = store::Store::load()?;
|
||||
let log = |msg: &str| eprintln!("[{}] {}", agent, msg);
|
||||
|
|
@ -28,26 +29,29 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
|
|||
};
|
||||
|
||||
if !resolved_targets.is_empty() {
|
||||
// Queue one daemon task per target node
|
||||
// --local or daemon unavailable: run directly
|
||||
if local || crate::agents::daemon::send_rpc_pub("ping").is_none() {
|
||||
if !local {
|
||||
eprintln!("Daemon not running — falling back to local execution");
|
||||
}
|
||||
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(());
|
||||
}
|
||||
|
||||
// Queue to daemon
|
||||
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(());
|
||||
}
|
||||
if crate::agents::daemon::send_rpc_pub(&cmd).is_some() {
|
||||
queued += 1;
|
||||
}
|
||||
}
|
||||
eprintln!("[{}] queued {} tasks to daemon", agent, queued);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue