poc-memory agent run --debug: dump prompt and response

Add --debug flag that prints the full prompt and LLM response to
stdout, making it easy to iterate on agent prompts. Also adds
prompt field to AgentResult so callers can inspect what was sent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kent Overstreet 2026-03-16 19:09:18 -04:00
parent c7509a0c2d
commit 7fe55e28bd
4 changed files with 32 additions and 7 deletions

View file

@ -548,6 +548,7 @@ pub fn resolve_naming(
/// Result of running a single agent through the common pipeline.
pub struct AgentResult {
pub prompt: String,
pub output: String,
pub actions: Vec<Action>,
pub no_ops: usize,
@ -693,6 +694,7 @@ pub fn run_one_agent(
}
Ok(AgentResult {
prompt: agent_batch.prompt,
output,
actions,
no_ops,

View file

@ -5,16 +5,29 @@ use crate::store::StoreView;
use crate::agents::llm;
use std::sync::atomic::{AtomicUsize, Ordering};
pub fn cmd_run_agent(agent: &str, count: usize, dry_run: bool) -> Result<(), String> {
pub fn cmd_run_agent(agent: &str, count: usize, dry_run: bool, debug: bool) -> Result<(), String> {
if dry_run {
std::env::set_var("POC_MEMORY_DRY_RUN", "1");
}
let mut store = store::Store::load()?;
let log = |msg: &str| eprintln!("[{}] {}", agent, msg);
let (total, applied) = crate::agents::knowledge::run_and_apply_with_log(
&mut store, agent, count, "test", &log,
)?;
eprintln!("[{}] {} actions, {} applied", agent, total, applied);
if debug {
// Debug mode: show prompt, call LLM, show response — don't apply
let result = crate::agents::knowledge::run_one_agent(
&mut store, agent, count, "test", &log,
)?;
eprintln!("\n=== PROMPT ({} bytes) ===\n", result.prompt.len());
println!("{}", result.prompt);
eprintln!("\n=== RESPONSE ({} bytes) ===\n", result.output.len());
println!("{}", result.output);
eprintln!("\n=== PARSED: {} actions, {} no-ops ===", result.actions.len(), result.no_ops);
} else {
let (total, applied) = crate::agents::knowledge::run_and_apply_with_log(
&mut store, agent, count, "test", &log,
)?;
eprintln!("[{}] {} actions, {} applied", agent, total, applied);
}
Ok(())
}

View file

@ -568,6 +568,9 @@ enum AgentCmd {
/// Dry run — set POC_MEMORY_DRY_RUN=1 so mutations are no-ops
#[arg(long)]
dry_run: bool,
/// Debug — print full prompt and response
#[arg(long)]
debug: bool,
},
/// Show spaced repetition replay queue
#[command(name = "replay-queue")]
@ -811,8 +814,8 @@ fn main() {
AgentCmd::FactMine { path, batch, dry_run, output, 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::Run { agent, count, dry_run }
=> cli::agent::cmd_run_agent(&agent, count, dry_run),
AgentCmd::Run { agent, count, dry_run, debug }
=> cli::agent::cmd_run_agent(&agent, count, dry_run, debug),
AgentCmd::ReplayQueue { count } => cli::agent::cmd_replay_queue(count),
AgentCmd::Evaluate { matchups, model, dry_run }
=> cli::agent::cmd_evaluate_agents(matchups, &model, dry_run),