From b30f5ca6dfa1c410b613ab39264d3503e8ab491e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 11 Mar 2026 22:06:46 -0400 Subject: [PATCH] fix(llm): gptel-magit: non-string responses Resolves an upstream issue (ragnard/gptel-magit#9) where gptel-magit requests may return a non-string response, causing a type error. The solution was adapted from an upstream PR (ragnard/gptel-magit#4). Ref: ragnard/gptel-magit#9 Ref: ragnard/gptel-magit#4 --- modules/tools/llm/config.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/tools/llm/config.el b/modules/tools/llm/config.el index a34f71108..726cdbf3b 100644 --- a/modules/tools/llm/config.el +++ b/modules/tools/llm/config.el @@ -39,7 +39,20 @@ (if (eq gptel-magit-backend gptel--openrouter) '(:reasoning (:exclude t :effort "minimal")) nil))) - (apply fn args)))) + (apply fn args))) + + ;; HACK: Responses from the system/API calls might not be a string, causing + ;; type errors. + ;; REVIEW: Remove these when ragnard/gptel-magit#9 is resolved OR + ;; ragnard/gptel-magit#4 is merged. + (defadvice! +llm--fix-gptel-magit--non-string-responses-a (plist) + :filter-args #'gptel-magit--request + (when-let* ((callback (plist-get plist :callback))) + (cl-callf plist-put plist :callback + (lambda (response info) + (when (stringp response) + (funcall callback response info))))) + plist)) (use-package! ob-gptel