branch: externals/llm
commit 1bd69ed78184596e3389cd115688b055888e71cb
Author: Andrew Hyatt <ahy...@gmail.com>
Commit: GitHub <nore...@github.com>

    Fix bug in streaming with reasoning models (#195)
    
    When only reasoning results have come in, we shouldn't call callbacks
    with `nil` values when `multi-output` is off.
    
    This will fix https://github.com/ahyatt/ekg/issues/203.
---
 NEWS.org              | 1 +
 llm-provider-utils.el | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index e531e0bc70..4d629d3d88 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -3,6 +3,7 @@
 - Fix bug in ollama batch embedding generation.
 - Add Qwen 3 and Gemma 3 to model list.
 - Fix broken model error message
+- Fix reasoning model and streaming incompatibility
 * Version 0.25.0
 - Add =llm-ollama-authed= provider, which is like Ollama but takes a key.
 - Set Gemini 2.5 Pro to be the default Gemini model
diff --git a/llm-provider-utils.el b/llm-provider-utils.el
index c2035d58cd..0a6d7af107 100644
--- a/llm-provider-utils.el
+++ b/llm-provider-utils.el
@@ -424,10 +424,11 @@ Any strings will be concatenated, integers will be added, 
etc."
                     (setq current-result
                           (llm-provider-utils-streaming-accumulate 
current-result s))
                     (when partial-callback
-                      (llm-provider-utils-callback-in-buffer
-                       buf partial-callback (if multi-output
-                                                current-result
-                                              (plist-get current-result 
:text)))))
+                      (when-let* ((callback-val (if multi-output
+                                                    current-result
+                                                  (plist-get current-result 
:text))))
+                        (llm-provider-utils-callback-in-buffer
+                         buf partial-callback callback-val))))
                   (lambda (err)
                     (llm-provider-utils-callback-in-buffer
                      buf error-callback 'error

Reply via email to