Register a tool If a tool with the same name already exists as a builtin, the registration is rejected to prevent shadowing of core tools.
(&self, tool: Arc<dyn Tool>)
| 72 | /// If a tool with the same name already exists as a builtin, the registration |
| 73 | /// is rejected to prevent shadowing of core tools. |
| 74 | pub fn register(&self, tool: Arc<dyn Tool>) { |
| 75 | let name = tool.name().to_string(); |
| 76 | let builtins = self.builtins.read().unwrap(); |
| 77 | if builtins.contains(&name) { |
| 78 | tracing::warn!( |
| 79 | "Rejected registration of tool '{}': cannot shadow builtin", |
| 80 | name |
| 81 | ); |
| 82 | return; |
| 83 | } |
| 84 | drop(builtins); |
| 85 | let mut tools = self.tools.write().unwrap(); |
| 86 | tracing::debug!("Registering tool: {}", name); |
| 87 | tools.insert(name, tool); |
| 88 | } |
| 89 | |
| 90 | /// Unregister a tool by name |
| 91 | /// |