fix: Agent tools can only be modified via .tool enable/disable using tools in the allowed whitelist in the agent

This commit is contained in:
2026-07-17 15:42:57 -06:00
parent 39a654a79e
commit a606ea552d
2 changed files with 141 additions and 28 deletions
+16 -13
View File
@@ -43,6 +43,8 @@ pub struct Agent {
graph_rags: HashMap<String, Arc<Rag>>,
model: Model,
vault: GlobalVault,
is_graph: bool,
enabled_tools: Option<Vec<String>>,
}
impl Agent {
@@ -243,6 +245,8 @@ impl Agent {
graph_rags,
model,
vault: app_state.vault.clone(),
is_graph: graph_for_rag.is_some(),
enabled_tools: None,
})
}
@@ -339,6 +343,10 @@ impl Agent {
&self.name
}
pub fn is_graph(&self) -> bool {
self.is_graph
}
pub fn functions(&self) -> &Functions {
&self.functions
}
@@ -580,7 +588,7 @@ impl RoleLike for Agent {
}
fn enabled_tools(&self) -> Option<Vec<String>> {
None
self.enabled_tools.clone()
}
fn enabled_mcp_servers(&self) -> Option<Vec<String>> {
@@ -605,18 +613,13 @@ impl RoleLike for Agent {
}
fn set_enabled_tools(&mut self, value: Option<Vec<String>>) {
match value {
Some(tools) => {
self.config.global_tools = tools
.into_iter()
.map(|v| v.trim().to_string())
.filter(|v| !v.is_empty())
.collect::<Vec<_>>();
}
None => {
self.config.global_tools.clear();
}
}
self.enabled_tools = value.map(|tools| {
tools
.into_iter()
.map(|v| v.trim().to_string())
.filter(|v| !v.is_empty())
.collect::<Vec<_>>()
});
}
fn set_enabled_mcp_servers(&mut self, value: Option<Vec<String>>) {