branch: externals/ellama
commit 3c1ca537ead8e0de21f6aea9554f7edfac04d307
Author: Sergey Kostyaev <[email protected]>
Commit: Sergey Kostyaev <[email protected]>
Add option to disable undo on LLM errors
Added `ellama-undo-on-error` variable to control whether buffer changes are
rolled back when LLM requests fail. When non-nil, the system undoes partial
text
on errors (previous default behavior). When nil, partial responses are
preserved
even if errors occur.
---
ellama.el | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/ellama.el b/ellama.el
index 7b5dde1a60..d0d5dc6091 100644
--- a/ellama.el
+++ b/ellama.el
@@ -598,6 +598,12 @@ sub-agent sessions started by tools."
"Enable debug."
:type 'boolean)
+(defcustom ellama-undo-on-error nil
+ "Undo buffer changes when a request fails.
+When non-nil, `ellama-stream' rolls back any partial text insertion
+into the buffer if the LLM call raises an error."
+ :type 'boolean)
+
(defcustom ellama-sessions-directory (file-truename
(file-name-concat
user-emacs-directory
@@ -3224,7 +3230,9 @@ REQUEST-CONTEXT is request context."
(progn
(ellama--append-tool-error-to-prompt prompt msg)
(funcall retry-fn))
- (cancel-change-group ellama--change-group)
+ (if ellama-undo-on-error
+ (cancel-change-group ellama--change-group)
+ (accept-change-group ellama--change-group))
(when ellama-spinner-enabled
(spinner-stop))
(funcall errcb msg)