]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
cli : persist reasoning_content in chat history (#26362)
authorNico <redacted>
Sat, 1 Aug 2026 16:03:32 +0000 (12:03 -0400)
committerGitHub <redacted>
Sat, 1 Aug 2026 16:03:32 +0000 (18:03 +0200)
* cli : persist reasoning_content in chat history

llama-cli collected reasoning from the stream for display but only
stored assistant content in messages, so --reasoning-preserve could
not re-inject prior thoughts on later turns.

tools/cli/cli-context.cpp

index 0de8f69025ce89c64fc482146f6454bde2c85465..3d801b73d4c1f5b3a9e382b5c168ecf84bb186b4 100644 (file)
@@ -624,10 +624,14 @@ int cli_context::run() {
         generated_content content;
         generate_completion(content, timings);
 
-        impl->messages.push_back({
+        json assistant_msg = {
             {"role",    "assistant"},
             {"content", content.content}
-        });
+        };
+        if (!content.reasoning.empty()) {
+            assistant_msg["reasoning_content"] = content.reasoning;
+        }
+        impl->messages.push_back(std::move(assistant_msg));
 
         if (output_file) {
             std::string out_content = "Assistant:\n";