branch: elpa/gptel
commit 054f59c38a73e52cf179f5866ef07f5dd23512e0
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-request: Fix message about pending tool calls
* gptel-request.el (gptel--handle-tool-use): Set a
flag (:tool-pending) in the INFO plist when there are pending tool
calls.
* gptel.el (gptel--update-tool-ask): In gptel-mode, check this
flag to message the user about pending calls. Fix bug where the
header line says "Run tools?" when there are no pending calls and
async tools are running.
---
gptel-request.el | 1 +
gptel.el | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/gptel-request.el b/gptel-request.el
index 5d99438c8ba..cabdc3055f0 100644
--- a/gptel-request.el
+++ b/gptel-request.el
@@ -1718,6 +1718,7 @@ MACHINE is an instance of `gptel-fsm'"
(funcall process-tool-result result)))))))
tool-use)
(when pending-calls
+ (plist-put info :tool-pending t)
(funcall (plist-get info :callback)
(cons 'tool-call pending-calls) info))))))
diff --git a/gptel.el b/gptel.el
index f6a15f1cf47..5b3553174aa 100644
--- a/gptel.el
+++ b/gptel.el
@@ -917,11 +917,11 @@ Run post-response hooks."
(defun gptel--update-tool-ask (fsm)
"Update gptel's status when there are pending tool calls."
- (when (cl-some (lambda (tc) (not (plist-get tc :result)))
- (plist-get (gptel-fsm-info fsm) :tool-use))
+ (when (plist-get (gptel-fsm-info fsm) :tool-pending)
(setq gptel--fsm-last fsm)
- (when gptel-mode (gptel--update-status
- (format " Run tools?" ) 'mode-line-emphasis))))
+ (plist-put (gptel-fsm-info fsm) :tool-pending nil)
+ (when gptel-mode
+ (gptel--update-status " Run tools?" 'mode-line-emphasis))))
(defun gptel--update-abort (fsm)
"Update gptel's status when aborting a request."