branch: externals/ellama
commit 9a3b78149fd33a6050ed398be8b672b3a5b0c347
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>
Fix async tools confirmation
Use callback function to return result to the agent.
---
ellama-tools.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/ellama-tools.el b/ellama-tools.el
index aca8fabf5f..c2dfc82087 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -203,9 +203,14 @@ approved, \"Forbidden by the user\" otherwise."
((eq answer ?r)
(setq result (read-string "Answer to the agent: "))
nil))))
- (when result (if (stringp result)
- result
- (json-encode result)))))))))
+ (when result (let ((result-str (if (stringp result)
+ result
+ (json-encode result)))
+ (cb (and args
+ (functionp (car args))
+ (car args))))
+ (if cb (funcall cb result-str)
+ result-str)))))))))
(defun ellama-tools-wrap-with-confirm (tool-plist)
"Wrap a tool's function with automatic confirmation.