]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server: support "reasoning_effort": "none" in OAI API (#26045)
authorNigel Bosch <redacted>
Fri, 24 Jul 2026 17:19:10 +0000 (12:19 -0500)
committerGitHub <redacted>
Fri, 24 Jul 2026 17:19:10 +0000 (19:19 +0200)
* support "reasoning_effort": "none" in OAI API

* handle reasoning.effort: "none" in OAI responses API

* clarify non-"none" values of reasoning_effort have no effect

* use json_value instead of body.at

tools/server/README.md
tools/server/server-chat.cpp
tools/server/server-common.cpp

index e6b27a55760829228c41e58a5a9cc3dacecd724f..d34565455455891edfdb50cac1fbaf79545764d3 100644 (file)
@@ -1247,6 +1247,8 @@ The `response_format` parameter supports both plain JSON output (e.g. `{"type":
 
 `chat_template_kwargs`: Allows sending additional parameters to the json templating system. For example: `{"enable_thinking": false}`
 
+`reasoning_effort`: If set to `none`, reasoning will be disabled for this request. Other values (e.g., `low`, `max`) have no effect on reasoning.
+
 `reasoning_format`: The reasoning format to be parsed. If set to `none`, it will output the raw generated text.
 
 `reasoning_control`: Arms realtime reasoning control for this completion so it can be ended early via `/v1/chat/completions/control`. Defaults to `false`.
index 31f94e0233071c1ab45f36f49002b2c8aa4c2388..0322e54ccea8006070c4c6b585faf3ff0094ec84 100644 (file)
@@ -283,6 +283,15 @@ json server_chat_convert_responses_to_chatcmpl(const json & response_body) {
         chatcmpl_body["max_tokens"] = response_body["max_output_tokens"];
     }
 
+    if (response_body.contains("reasoning")) {
+        // Only "effort" is handled so far
+        const json & reasoning = response_body.at("reasoning");
+        if (reasoning.contains("effort")) {
+            chatcmpl_body["reasoning_effort"] = reasoning.at("effort");
+        }
+        chatcmpl_body.erase("reasoning");
+    }
+
     return chatcmpl_body;
 }
 
index 78b5c6819b03ed8f4b5c8fea85b0fc1d593f777e..da58049308e70c13125d37c976acb80573e046dc 100644 (file)
@@ -1086,6 +1086,14 @@ json oaicompat_chat_params_parse(
         throw std::invalid_argument("invalid type for \"enable_thinking\" (expected boolean, got string)");
     }
 
+    // Parse also the OAI "reasoning_effort": "none" specific value
+    if (body.contains("reasoning_effort")) {
+        auto reasoning_effort = json_value(body, "reasoning_effort", std::string(""));
+        if (reasoning_effort == "none") {
+            inputs.enable_thinking = false;
+        } // other reasoning_effort values are model-specific and not yet handled
+    }
+
     inputs.force_pure_content = opt.force_pure_content;
 
     // Apply chat template to the list of messages