branch: externals/llm
commit b529c0803bae4a074376a5b4c9008bbb7409d8cf
Author: Andrew Hyatt <[email protected]>
Commit: GitHub <[email protected]>

    Add support for Open AI compatible reasoning_content blocks (#258)
    
    This is fulfilling the request in
    https://github.com/ahyatt/llm/discussions/257.
---
 NEWS.org      | 3 ++-
 llm-openai.el | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/NEWS.org b/NEWS.org
index 4a3a6880a1..260f58d1d1 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,5 +1,6 @@
 * Version 0.30.1
-- Add Claude Sonnet 4.6
+- Add Claude Sonnet 4.6.
+- Add support for Open AI compatible =reasoning_content= blocks.
 * Version 0.30.0
 - Add =:input-tokens= and =:output-tokens= to multioutput result.
 - Added Qwen 3.5, LFM2 and LFM 2.5 Thinking
diff --git a/llm-openai.el b/llm-openai.el
index 31e51aaed3..9f862f0390 100644
--- a/llm-openai.el
+++ b/llm-openai.el
@@ -351,6 +351,13 @@ STREAMING if non-nil, turn on response streaming."
                          (assoc-default 'message
                                         (aref (assoc-default 'choices 
response) 0)))))
 
+;; Several Open AI compatible providers such as oMLX include a
+;; "reasoning_content" field in the response.
+(cl-defmethod llm-provider-extract-reasoning ((_ llm-openai-compatible) 
response)
+  (assoc-default 'reasoning_content
+                 (assoc-default 'message (aref (cdr (assoc 'choices response)) 
0))))
+
+
 (cl-defmethod llm-provider-populate-tool-uses ((_ llm-openai) prompt tool-uses)
   (llm-provider-utils-append-to-prompt prompt tool-uses nil 'assistant))
 

Reply via email to