branch: externals/ellama
commit c539524b5ee5c7de5fca58563b25675d9198218b
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>
Improve agent response result handling
Updated result encoding to return "done" for nil results instead of causing
potential errors. Simplified the conditional structure with a let binding.
---
ellama-tools.el | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/ellama-tools.el b/ellama-tools.el
index c2dfc82087..3566a58fe7 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -203,14 +203,16 @@ approved, \"Forbidden by the user\" otherwise."
((eq answer ?r)
(setq result (read-string "Answer to the agent: "))
nil))))
- (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)))))))))
+ (let ((result-str (if (stringp result)
+ result
+ (if result
+ (json-encode result)
+ "done")))
+ (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.