From 850a54acdf6475209fa7305f98ec65bc2428ae06 Mon Sep 17 00:00:00 2001 From: infosave2007 Date: Thu, 23 Jul 2026 16:34:49 +0300 Subject: [PATCH] fix: enable_thinking not sent in streaming path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs: 1. run_stream() never merged per-model/server config (think_budget, temperature, etc.) into the request — unlike run_inner(). Now both paths apply the same config merge. 2. to_wire() was missing the enable_thinking bool conversion line (lost in a prior revert). Restored: think_budget=0 → enable_thinking=false. --- src/pipeline.rs | 32 +++++++++++++++++++++++++++++++- src/providers/openai.rs | 2 ++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/pipeline.rs b/src/pipeline.rs index 226b5e7..7f14e1b 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -472,7 +472,37 @@ impl Pipeline { model_id, route_source ); - match provider.chat_stream(req.clone()).await { + // Merge per-model/server config (same as run_inner). + let mut req_call = req.clone(); + if let Some(m_cfg) = live.cfg.models.iter().find(|m| m.id == model_id) { + if req_call.params.temperature.is_none() { + req_call.params.temperature = m_cfg.temperature; + } + if req_call.params.top_p.is_none() { + req_call.params.top_p = m_cfg.top_p; + } + if req_call.params.max_tokens.is_none() { + req_call.params.max_tokens = m_cfg.max_tokens; + } + if req_call.params.think_budget.is_none() { + req_call.params.think_budget = m_cfg.think_budget; + } + } else if let Some(s_cfg) = live.cfg.cmf.servers.iter().find(|s| s.id == model_id) { + if req_call.params.temperature.is_none() { + req_call.params.temperature = s_cfg.temperature; + } + if req_call.params.top_p.is_none() { + req_call.params.top_p = s_cfg.top_p; + } + if req_call.params.max_tokens.is_none() { + req_call.params.max_tokens = s_cfg.max_tokens; + } + if req_call.params.think_budget.is_none() { + req_call.params.think_budget = s_cfg.think_budget; + } + } + + match provider.chat_stream(req_call).await { Ok(stream) => { let info = RouteInfo { task_label: decision.task_label.clone(), diff --git a/src/providers/openai.rs b/src/providers/openai.rs index 33aeed1..a559bbb 100644 --- a/src/providers/openai.rs +++ b/src/providers/openai.rs @@ -51,6 +51,8 @@ impl OpenAiProvider { if let Some(tb) = req.params.think_budget { body["think_budget"] = tb.into(); body["reasoning_effort"] = tb.into(); + // cortiq serve uses enable_thinking (bool): 0 = off, >0 = on + body["enable_thinking"] = (tb > 0).into(); } if !req.tools.is_empty() { body["tools"] = serde_json::Value::Array(req.tools.clone());