branch: externals/ellama
commit b8fddfc4dc3b2003e5b304b06e48167f7753da49
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>
Trim shell command output and return nil for async tools
Trim trailing newlines from async shell command results and ensure proper
return
value for async tools to maintain compatibility with the llm library.
---
ellama-tools.el | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/ellama-tools.el b/ellama-tools.el
index 4c1cc45a28..1310be7106 100644
--- a/ellama-tools.el
+++ b/ellama-tools.el
@@ -520,8 +520,15 @@ CALLBACK – function called once with the result string."
(start-process "*ellama-shell-command*" buf shell-file-name
shell-command-switch cmd)
(lambda (process _)
(when (not (process-live-p process))
- (funcall callback (with-current-buffer buf (buffer-string)))
- (kill-buffer buf))))))
+ (funcall callback
+ ;; we need to trim trailing newline
+ (string-trim-right
+ (with-current-buffer buf (buffer-string))
+ "\n"))
+ (kill-buffer buf)))))
+ ;; async tool should always return nil
+ ;; to work properly with the llm library
+ nil)
(ellama-tools-define-tool
'(:function