cli: add --state-dir flag to agent run
Override the agent output/input directory for manual testing.
Sets POC_AGENT_OUTPUT_DIR so output() writes there and
{{input:key}} reads from there.
Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
4b32716d3e
commit
e176639437
2 changed files with 18 additions and 4 deletions
|
|
@ -3,12 +3,18 @@
|
||||||
use crate::store;
|
use crate::store;
|
||||||
use crate::agents::llm;
|
use crate::agents::llm;
|
||||||
|
|
||||||
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, local: bool) -> Result<(), String> {
|
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, local: bool, state_dir: Option<&str>) -> Result<(), String> {
|
||||||
// Mark as agent so tool calls (e.g. poc-memory render) don't
|
// Mark as agent so tool calls (e.g. poc-memory render) don't
|
||||||
// pollute the user's seen set as a side effect
|
// pollute the user's seen set as a side effect
|
||||||
// SAFETY: single-threaded at this point (CLI startup, before any agent work)
|
// SAFETY: single-threaded at this point (CLI startup, before any agent work)
|
||||||
unsafe { std::env::set_var("POC_AGENT", "1"); }
|
unsafe { std::env::set_var("POC_AGENT", "1"); }
|
||||||
|
|
||||||
|
// Override agent output/state directory if specified
|
||||||
|
if let Some(dir) = state_dir {
|
||||||
|
std::fs::create_dir_all(dir).map_err(|e| format!("create state dir: {}", e))?;
|
||||||
|
unsafe { std::env::set_var("POC_AGENT_OUTPUT_DIR", dir); }
|
||||||
|
}
|
||||||
|
|
||||||
if dry_run {
|
if dry_run {
|
||||||
unsafe { std::env::set_var("POC_MEMORY_DRY_RUN", "1"); }
|
unsafe { std::env::set_var("POC_MEMORY_DRY_RUN", "1"); }
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +92,12 @@ pub fn cmd_consolidate_batch(count: usize, auto: bool, agent: Option<String>) ->
|
||||||
|
|
||||||
if let Some(agent_name) = agent {
|
if let Some(agent_name) = agent {
|
||||||
let batch = crate::agents::prompts::agent_prompt(&store, &agent_name, count)?;
|
let batch = crate::agents::prompts::agent_prompt(&store, &agent_name, count)?;
|
||||||
println!("{}", batch.prompt);
|
for (i, p) in batch.prompts.iter().enumerate() {
|
||||||
|
if batch.prompts.len() > 1 {
|
||||||
|
println!("=== STEP {} ===\n", i + 1);
|
||||||
|
}
|
||||||
|
println!("{}", p);
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
crate::agents::prompts::consolidation_batch(&store, count, auto)
|
crate::agents::prompts::consolidation_batch(&store, count, auto)
|
||||||
|
|
|
||||||
|
|
@ -614,6 +614,9 @@ enum AgentCmd {
|
||||||
/// Run locally instead of queuing to daemon
|
/// Run locally instead of queuing to daemon
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
local: bool,
|
local: bool,
|
||||||
|
/// Directory for agent output/input state (persists across runs)
|
||||||
|
#[arg(long)]
|
||||||
|
state_dir: Option<String>,
|
||||||
},
|
},
|
||||||
/// Show spaced repetition replay queue
|
/// Show spaced repetition replay queue
|
||||||
#[command(name = "replay-queue")]
|
#[command(name = "replay-queue")]
|
||||||
|
|
@ -862,8 +865,8 @@ fn main() {
|
||||||
AgentCmd::FactMine { path, batch, dry_run, output, min_messages }
|
AgentCmd::FactMine { path, batch, dry_run, output, min_messages }
|
||||||
=> cli::agent::cmd_fact_mine(&path, batch, dry_run, output.as_deref(), min_messages),
|
=> cli::agent::cmd_fact_mine(&path, batch, dry_run, output.as_deref(), min_messages),
|
||||||
AgentCmd::FactMineStore { path } => cli::agent::cmd_fact_mine_store(&path),
|
AgentCmd::FactMineStore { path } => cli::agent::cmd_fact_mine_store(&path),
|
||||||
AgentCmd::Run { agent, count, target, query, dry_run, local }
|
AgentCmd::Run { agent, count, target, query, dry_run, local, state_dir }
|
||||||
=> cli::agent::cmd_run_agent(&agent, count, &target, query.as_deref(), dry_run, local),
|
=> cli::agent::cmd_run_agent(&agent, count, &target, query.as_deref(), dry_run, local, state_dir.as_deref()),
|
||||||
AgentCmd::ReplayQueue { count } => cli::agent::cmd_replay_queue(count),
|
AgentCmd::ReplayQueue { count } => cli::agent::cmd_replay_queue(count),
|
||||||
AgentCmd::Evaluate { matchups, model, dry_run }
|
AgentCmd::Evaluate { matchups, model, dry_run }
|
||||||
=> cli::agent::cmd_evaluate_agents(matchups, &model, dry_run),
|
=> cli::agent::cmd_evaluate_agents(matchups, &model, dry_run),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue