From 82eeb9807e0490af181d21fcfde856fe15a6c722 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 15 Apr 2026 02:41:40 -0400 Subject: [PATCH] Add -tool exclusion syntax, exclude delete/restore for agents memory_delete and memory_restore are now in memory_tools() (available via MCP for CLI). Agent tool lists support "-tool_name" to exclude. Agents automatically exclude memory_delete and memory_restore. Co-Authored-By: Kent Overstreet --- src/agent/oneshot.rs | 12 ++++++++++++ src/agent/tools/memory.rs | 18 ++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/agent/oneshot.rs b/src/agent/oneshot.rs index b0d6a33..139af49 100644 --- a/src/agent/oneshot.rs +++ b/src/agent/oneshot.rs @@ -421,8 +421,17 @@ pub async fn run_one_agent( }; // Base memory tools + extras from agent def (matching unconscious.rs pattern) + // Tools prefixed with "-" are excluded (e.g., "-memory_delete") let base_tools = super::tools::memory::memory_tools().to_vec(); let extra_tools = super::tools::memory::journal_tools().to_vec(); + + // Collect exclusions (tools starting with "-") + let mut exclusions: Vec<&str> = def.tools.iter() + .filter_map(|t| t.strip_prefix('-')) + .collect(); + // Always exclude destructive tools from agents + exclusions.extend(&["memory_delete", "memory_restore"]); + let mut effective_tools: Vec = if def.tools.is_empty() { let mut all = base_tools; all.extend(extra_tools); @@ -430,12 +439,15 @@ pub async fn run_one_agent( } else { let mut tools = base_tools; for name in &def.tools { + if name.starts_with('-') { continue; } // skip exclusions if let Some(t) = extra_tools.iter().find(|t| t.name == *name) { tools.push(t.clone()); } } tools }; + // Apply exclusions + effective_tools.retain(|t| !exclusions.contains(&t.name)); effective_tools.push(super::tools::Tool { name: "output", description: "Produce a named output value for passing between steps.", diff --git a/src/agent/tools/memory.rs b/src/agent/tools/memory.rs index 9f82df2..b525925 100644 --- a/src/agent/tools/memory.rs +++ b/src/agent/tools/memory.rs @@ -12,8 +12,8 @@ use crate::hippocampus::{access, memory_rpc, StoreAccess}; // Re-export typed API from hippocampus for backward compatibility pub use crate::hippocampus::{ memory_render, memory_write, memory_search, memory_link_set, memory_link_add, - memory_delete, memory_history, memory_weight_set, memory_rename, memory_supersede, - memory_query, memory_links, + memory_delete, memory_restore, memory_history, memory_weight_set, memory_rename, + memory_supersede, memory_query, memory_links, journal_tail, journal_new, journal_update, graph_topology, graph_health, graph_communities, graph_normalize_strengths, graph_link_impact, graph_hubs, graph_trace, @@ -177,6 +177,7 @@ memory_tool!(memory_search, ref, keys: [Vec], max_hops: [Option], e memory_tool!(memory_link_set, mut, source: [str], target: [str], strength: [f32]); memory_tool!(memory_link_add, mut, source: [str], target: [str]); memory_tool!(memory_delete, mut, key: [str]); +memory_tool!(memory_restore, mut, key: [str]); memory_tool!(memory_history, ref, key: [str], full: [Option]); memory_tool!(memory_weight_set, mut, key: [str], weight: [f32]); memory_tool!(memory_rename, mut, old_key: [str], new_key: [str]); @@ -208,7 +209,7 @@ memory_tool!(graph_trace, ref, key: [str]); // ── Definitions ──────────────────────────────────────────────── -pub fn memory_tools() -> [super::Tool; 18] { +pub fn memory_tools() -> [super::Tool; 20] { use super::Tool; macro_rules! tool { ($name:ident, $desc:expr, $params:expr) => { @@ -263,7 +264,16 @@ pub fn memory_tools() -> [super::Tool; 18] { "properties": { "source": {"type": "string"}, "target": {"type": "string"} }, "required": ["source", "target"] }"#), - // NOTE: memory_delete not exposed to agents - use memory_supersede instead + tool!(memory_delete, "Soft-delete a node.", r#"{ + "type": "object", + "properties": { "key": {"type": "string"} }, + "required": ["key"] + }"#), + tool!(memory_restore, "Restore a deleted node.", r#"{ + "type": "object", + "properties": { "key": {"type": "string"} }, + "required": ["key"] + }"#), tool!(memory_history, "Show version history for a node.", r#"{ "type": "object", "properties": { "key": {"type": "string"}, "full": {"type": "boolean"} },