agent: move oneshot execution from subconscious to agent module

Move agent execution machinery (run_one_agent, spawn_agent, PID
tracking) from subconscious/knowledge.rs to agent/oneshot.rs — the
agent module owns execution, subconscious owns scheduling and defs.

Delete subconscious/llm.rs — callers now use api::call_api_with_tools_sync
directly. Audit and compare inline the call; oneshot inlines tool
filtering.

Update all callers: consolidate, daemon, subconscious, cli/agent.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-04 17:25:10 -04:00 committed by Kent Overstreet
parent 1457a1b50d
commit 0f4ca9e2f2
10 changed files with 43 additions and 106 deletions

View file

@ -1,7 +1,6 @@
// cli/agent.rs — agent subcommand handlers
use crate::store;
use crate::agents::llm;
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
@ -60,7 +59,7 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
for (i, key) in resolved_targets.iter().enumerate() {
println!("[{}] [{}/{}] {}", 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(
if let Err(e) = crate::agent::oneshot::run_one_agent_with_keys(
&mut store, agent, &[key.clone()], count, "test", &log,
) {
println!("[{}] ERROR on {}: {}", agent, key, e);
@ -80,7 +79,7 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
println!("[{}] queued {} tasks to daemon", agent, queued);
} else {
// Local execution (--local, --debug, dry-run, or daemon unavailable)
crate::agents::knowledge::run_one_agent(
crate::agent::oneshot::run_one_agent(
&mut store, agent, count, "test", &log,
)?;
}
@ -400,7 +399,8 @@ fn llm_compare(
let prompt = build_compare_prompt(a, b);
let _ = model; // model selection handled by API backend config
let response = llm::call_simple("compare", &prompt)?;
let response = crate::subconscious::api::call_api_with_tools_sync(
"compare", &[prompt], &[], None, 10, &[], None, &|_| {})?;
let response = response.trim().to_uppercase();
if response.contains("BETTER: B") {