agents: tool-enabled LLM calls + DELETE action support

Add call_for_def() that threads model and tools from agent definitions
through to claude CLI. Tool-enabled agents get --allowedTools instead
of --tools "" and a longer 15-minute timeout for multi-turn work.

Add ActionKind::Delete with parse/apply support so agents can delete
nodes (used by organize agent for deduplication).

Use call_for_def() in run_one_agent instead of hardcoded call_sonnet.
This commit is contained in:
ProofOfConcept 2026-03-13 18:50:06 -04:00
parent 76b8e69749
commit bcf13c564a
3 changed files with 63 additions and 6 deletions

View file

@ -51,6 +51,9 @@ pub enum ActionKind {
Demote {
key: String,
},
Delete {
key: String,
},
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
@ -180,11 +183,28 @@ pub fn parse_demotes(text: &str) -> Vec<Action> {
.collect()
}
pub fn parse_deletes(text: &str) -> Vec<Action> {
let re = Regex::new(r"(?m)^DELETE\s+(\S+)").unwrap();
re.captures_iter(text)
.map(|cap| Action {
kind: ActionKind::Delete {
key: cap[1].to_string(),
},
confidence: Confidence::High,
weight: 1.0,
depth: 0,
applied: None,
rejected_reason: None,
})
.collect()
}
pub fn parse_all_actions(text: &str) -> Vec<Action> {
let mut actions = parse_write_nodes(text);
actions.extend(parse_links(text));
actions.extend(parse_refines(text));
actions.extend(parse_demotes(text));
actions.extend(parse_deletes(text));
actions
}
@ -243,7 +263,7 @@ fn agent_base_depth(agent: &str) -> Option<i32> {
pub fn compute_action_depth(db: &DepthDb, action: &Action, agent: &str) -> i32 {
match &action.kind {
ActionKind::Link { .. } | ActionKind::Demote { .. } => -1,
ActionKind::Link { .. } | ActionKind::Demote { .. } | ActionKind::Delete { .. } => -1,
ActionKind::Refine { key, .. } => db.get(key),
ActionKind::WriteNode { covers, .. } => {
if !covers.is_empty() {
@ -336,6 +356,9 @@ pub fn apply_action(
false
}
}
ActionKind::Delete { key } => {
store.delete_node(key).is_ok()
}
}
}
@ -582,7 +605,7 @@ pub fn run_one_agent(
.ok_or_else(|| format!("no .agent file for {}", agent_name))?;
let agent_batch = super::defs::run_agent(store, &def, batch_size)?;
let output = llm::call_sonnet(llm_tag, &agent_batch.prompt)?;
let output = llm::call_for_def(&def, &agent_batch.prompt)?;
// Store raw output for audit trail
let ts = store::compact_timestamp();
@ -920,6 +943,9 @@ fn run_cycle(
ActionKind::Demote { key } => {
eprintln!(" DEMOTE {}", key);
}
ActionKind::Delete { key } => {
eprintln!(" DELETE {}", key);
}
}
if apply_action(&mut store, action, agent_name, &timestamp, depth) {