branch: externals/ellama
commit 5ae0ae2788618aa1573bdcf2d3721a305455569b
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>
Prevent duplicate tools in ellama-tools
Added a test function to add-to-list to check if a tool with the same name
already exists before adding it to ellama-tools-available. This prevents
duplicate tools from being registered when enabling tools by name.
---
ellama-tools.el | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ellama-tools.el b/ellama-tools.el
index eec9a0b952..54ab31c65d 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -241,7 +241,10 @@ Returns a new tool definition with the :function wrapped."
TOOL-PLIST is a property list in the format expected by `llm-make-tool'."
(add-to-list
'ellama-tools-available
- (apply 'llm-make-tool (ellama-tools-wrap-with-confirm tool-plist))))
+ (apply 'llm-make-tool (ellama-tools-wrap-with-confirm tool-plist))
+ nil (lambda (a b)
+ (string= (plist-get a :name)
+ (plist-get b :name)))))
(defun ellama-tools-enable-by-name-tool (name)
"Add to `ellama-tools-enabled' each tool that matches NAME."