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

@ -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(())
}