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 <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-15 02:41:40 -04:00
parent a88428d642
commit 82eeb9807e
2 changed files with 26 additions and 4 deletions

View file

@ -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<super::tools::Tool> = 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.",