branch: externals/ellama
commit b15ec82318ff4a8883993343b1c40575d1facaf6
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>
Fix result delivery for already approved async tools
With async tools result should be delivered by calling callback function.
It was
already implemented for interactive approving, but was not implemented for
already
approved tools.
---
ellama-tools.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/ellama-tools.el b/ellama-tools.el
index 1310be7106..a349f27492 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -137,10 +137,17 @@ approved, \"Forbidden by the user\" otherwise."
((or confirmation
ellama-tools-allow-all
(cl-find function ellama-tools-allowed))
- (let ((result (apply function args)))
- (if (stringp result)
- result
- (json-encode result))))
+ (let* ((result (apply function args))
+ (result-str (if (stringp result)
+ result
+ (when result
+ (json-encode result))))
+ (cb (and args
+ (functionp (car args))
+ (car args))))
+ (if (and cb result-str)
+ (funcall cb result-str)
+ (or result-str "done"))))
;; Otherwise, ask for confirmation
(t
;; Generate prompt with truncated string arguments
@@ -206,7 +213,7 @@ approved, \"Forbidden by the user\" otherwise."
(let ((result-str (if (stringp result)
result
(when result
- (json-encode result))))
+ (json-encode result))))
(cb (and args
(functionp (car args))
(car args))))