SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Assistant: set the reasoning effort per API agent (#10241) (#10259)
Dahak Buildsbace1a1228b4
diff --git a/assets/locales/ar.json b/assets/locales/ar.jsonindex e5fb4c8bde..0d3eec8b2c 100644--- a/assets/locales/ar.json+++ b/assets/locales/ar.json@@ -4236,6 +4236,9 @@"ui.ai_permissions": "الأذونات","ui.ai_preset": "إعداد مسبق","ui.ai_protocol": "البروتوكول",+ "ui.ai_reasoning_effort": "مستوى الاستدلال",+ "ui.ai_reasoning_effort_field_hint": "فارغ = الافتراضي للمزوّد",+ "ui.ai_reasoning_effort_hint": "اختياري. يُرسل إلى نقطة النهاية على أنه `reasoning_effort`؛ تختلف القيم المقبولة حسب المزوّد (مثل `low` أو `high` أو `max`). لا تستبدل SolidCraft القيمة التي تحددها هنا أبدًا. اتركه فارغًا لعدم إرسال شيء والاحتفاظ بالافتراضي للمزوّد.","ui.ai_remove": "إزالة","ui.ai_request_timed_out": "استغرق النموذج أكثر من {seconds} ثانية. يمكنك رفع مهلة الطلب لنقطة النهاية هذه من التفضيلات › المساعد.","ui.ai_request_timeout": "مهلة الطلب",diff --git a/assets/locales/en.json b/assets/locales/en.jsonindex 7d907500d0..6ceca1aa9e 100644--- a/assets/locales/en.json+++ b/assets/locales/en.json@@ -4236,6 +4236,9 @@"ui.ai_permissions": "Permissions","ui.ai_preset": "Preset","ui.ai_protocol": "Protocol",+ "ui.ai_reasoning_effort": "Reasoning effort",+ "ui.ai_reasoning_effort_field_hint": "empty = provider default",+ "ui.ai_reasoning_effort_hint": "Optional. Sent to the endpoint as `reasoning_effort`; accepted values differ per provider (for example `low`, `high` or `max`). A value you set here is never replaced by SolidCraft. Leave empty to send nothing and keep the provider's default.","ui.ai_remove": "Remove","ui.ai_request_timed_out": "The model took longer than {seconds} s. You can raise the request timeout for this endpoint in Preferences › Assistant.","ui.ai_request_timeout": "Request timeout",diff --git a/assets/locales/he.json b/assets/locales/he.jsonindex 343687b3de..1429385ff0 100644--- a/assets/locales/he.json+++ b/assets/locales/he.json@@ -4236,6 +4236,9 @@"ui.ai_permissions": "הרשאות","ui.ai_preset": "תצורה מוכנה","ui.ai_protocol": "פרוטוקול",+ "ui.ai_reasoning_effort": "מאמץ ההסקה",+ "ui.ai_reasoning_effort_field_hint": "ריק = ברירת המחדל של הספק",+ "ui.ai_reasoning_effort_hint": "אופציונלי. נשלח לנקודת הקצה כ־`reasoning_effort`; הערכים המקובלים שונים מספק לספק (למשל `low`, `high` או `max`). SolidCraft לעולם לא תחליף את הערך שבחרת כאן. השאירו ריק כדי לא לשלוח דבר ולשמור על ברירת המחדל של הספק.","ui.ai_remove": "הסרה","ui.ai_request_timed_out": "המודל נזקק ליותר מ־{seconds} שניות. ניתן להגדיל את זמן ההמתנה לבקשה עבור נקודת קצה זו בהעדפות › עוזר.","ui.ai_request_timeout": "זמן המתנה לבקשה",diff --git a/assets/locales/ja.json b/assets/locales/ja.jsonindex 3962f22721..493313f13c 100644--- a/assets/locales/ja.json+++ b/assets/locales/ja.json@@ -4236,6 +4236,9 @@"ui.ai_permissions": "権限","ui.ai_preset": "プリセット","ui.ai_protocol": "プロトコル",+ "ui.ai_reasoning_effort": "推論の強度",+ "ui.ai_reasoning_effort_field_hint": "空 = プロバイダーの既定値",+ "ui.ai_reasoning_effort_hint": "任意。エンドポイントに `reasoning_effort` として送信されます。許可される値はプロバイダーによって異なります(例: `low`、`high`、`max`)。ここで設定した値が SolidCraft に置き換えられることはありません。空のままなら何も送信されず、プロバイダーの既定値が使われます。","ui.ai_remove": "削除","ui.ai_request_timed_out": "モデルの応答に {seconds} 秒以上かかりました。このエンドポイントのリクエストのタイムアウトは、環境設定 › アシスタントで長くできます。","ui.ai_request_timeout": "リクエストのタイムアウト",diff --git a/assets/locales/vi.json b/assets/locales/vi.jsonindex 1956a34c55..3c38c54138 100644--- a/assets/locales/vi.json+++ b/assets/locales/vi.json@@ -4236,6 +4236,9 @@"ui.ai_permissions": "Quyền hạn","ui.ai_preset": "Mẫu cấu hình sẵn","ui.ai_protocol": "Giao thức",+ "ui.ai_reasoning_effort": "Mức độ suy luận",+ "ui.ai_reasoning_effort_field_hint": "trống = mặc định của nhà cung cấp",+ "ui.ai_reasoning_effort_hint": "Tùy chọn. Được gửi tới điểm cuối dưới dạng `reasoning_effort`; các giá trị được chấp nhận khác nhau tùy nhà cung cấp (ví dụ: `low`, `high` hoặc `max`). Giá trị bạn đặt ở đây không bao giờ bị SolidCraft thay thế. Để trống để không gửi gì và giữ mặc định của nhà cung cấp.","ui.ai_remove": "Xóa","ui.ai_request_timed_out": "Mô hình phản hồi lâu hơn {seconds} giây. Bạn có thể tăng thời gian chờ yêu cầu cho điểm cuối này trong Tùy chọn › Trợ lý.","ui.ai_request_timeout": "Thời gian chờ yêu cầu",diff --git a/assets/locales/zh.json b/assets/locales/zh.jsonindex 07da530a77..7823dd0e66 100644--- a/assets/locales/zh.json+++ b/assets/locales/zh.json@@ -4236,6 +4236,9 @@"ui.ai_permissions": "权限","ui.ai_preset": "预设","ui.ai_protocol": "协议",+ "ui.ai_reasoning_effort": "推理强度",+ "ui.ai_reasoning_effort_field_hint": "留空 = 服务商默认",+ "ui.ai_reasoning_effort_hint": "可选。将作为 `reasoning_effort` 发送给端点;各服务商接受的值不同(例如 `low`、`high` 或 `max`)。您在此设置的值绝不会被 SolidCraft 替换。留空则不发送任何内容,沿用服务商默认值。","ui.ai_remove": "移除","ui.ai_request_timed_out": "模型用时超过 {seconds} 秒。可在“首选项 › 助手”中调高此端点的请求超时。","ui.ai_request_timeout": "请求超时",diff --git a/crates/ui-egui/src/agent_chat/agents.rs b/crates/ui-egui/src/agent_chat/agents.rsindex f5ad5e0d72..b7d6b8a81b 100644--- a/crates/ui-egui/src/agent_chat/agents.rs+++ b/crates/ui-egui/src/agent_chat/agents.rs@@ -113,6 +113,9 @@ pub struct AgentConfig {/// API: how long one model request may take, in seconds (clamped to/// [`MIN_REQUEST_TIMEOUT_S`]..=[`MAX_REQUEST_TIMEOUT_S`] where it is used).pub request_timeout_s: u64,+ /// API: the reasoning effort to send as `reasoning_effort`; empty sends nothing and the+ /// provider's own default applies (trimmed and length-capped by [`reasoning_effort`]).+ pub reasoning_effort: String,}impl Default for AgentConfig {@@ -127,6 +130,7 @@ impl Default for AgentConfig {ollama: false,key: false,request_timeout_s: DEFAULT_REQUEST_TIMEOUT_S,+ reasoning_effort: String::new(),}}}@@ -148,6 +152,15 @@ pub fn request_timeout_s(secs: f64) -> u64 {secs.round().clamp(MIN_REQUEST_TIMEOUT_S as f64, MAX_REQUEST_TIMEOUT_S as f64) as u64}+/// The longest reasoning effort an endpoint can be given (no provider names one near this).+pub const MAX_REASONING_EFFORT_LEN: usize = 64;++/// A reasoning effort as stored: trimmed, and capped so a hand-edited preferences file or the+/// control channel cannot carry an absurd value into every request. Empty means "send nothing".+pub fn reasoning_effort(raw: &str) -> String {+ raw.trim().chars().take(MAX_REASONING_EFFORT_LEN).collect()+}+/// An agent as the picker and the switcher show it.#[derive(Clone, Debug, PartialEq)]pub struct Entry {@@ -167,6 +180,8 @@ pub struct Entry {pub key: bool,/// API: seconds one model request may take (in range).pub request_timeout_s: u64,+ /// API: the reasoning effort to send, empty for none (trimmed, in length).+ pub reasoning_effort: String,/// Found installed, but its program didn't start when asked its version: why (#9034).pub problem: Option<String>,/// Found installed: the command that installs it again.@@ -187,6 +202,7 @@ impl Entry {model: c.model.clone(),key: c.key,request_timeout_s: c.request_timeout_s.clamp(MIN_REQUEST_TIMEOUT_S, MAX_REQUEST_TIMEOUT_S),+ reasoning_effort: reasoning_effort(&c.reasoning_effort),problem: None,install: "",}@@ -231,6 +247,7 @@ pub fn entries(app: &crate::SolveApp) -> Vec<Entry> {model: String::new(),key: false,request_timeout_s: DEFAULT_REQUEST_TIMEOUT_S,+ reasoning_effort: String::new(),problem: f.problem.clone(),install: f.install,}));@@ -401,4 +418,23 @@ mod tests {let back: AgentConfig = serde_json::from_value(serde_json::to_value(&saved).unwrap()).unwrap();assert_eq!(back, saved);}++ #[test]+ fn reasoning_effort_defaults_to_empty_and_is_trimmed_and_capped() {+ assert!(AgentConfig::default().reasoning_effort.is_empty());+ // An older preferences file has no effort: empty, so nothing is sent.+ let old: AgentConfig = serde_json::from_str(r#"{"id":"api-1","kind":"api","base_url":"http://localhost:11434/v1","model":"m"}"#).unwrap();+ assert!(old.reasoning_effort.is_empty());+ assert_eq!(reasoning_effort(" high "), "high");+ assert!(reasoning_effort(" ").is_empty());+ let long = reasoning_effort(&"x".repeat(500));+ assert_eq!(long.chars().count(), MAX_REASONING_EFFORT_LEN);+ let saved = AgentConfig { id: "api-2".into(), kind: Kind::Api, reasoning_effort: "max".into(), ..Default::default() };+ let back: AgentConfig = serde_json::from_value(serde_json::to_value(&saved).unwrap()).unwrap();+ assert_eq!(back, saved);+ // The entry carries it trimmed; a hand-edited over-long one is capped where used.+ assert_eq!(Entry::from_config(&saved).reasoning_effort, "max");+ let wild: AgentConfig = serde_json::from_str(&format!(r#"{{"id":"api-3","kind":"api","reasoning_effort":"{}"}}"#, "y".repeat(500))).unwrap();+ assert_eq!(Entry::from_config(&wild).reasoning_effort.chars().count(), MAX_REASONING_EFFORT_LEN);+ }}diff --git a/crates/ui-egui/src/agent_chat/api_client.rs b/crates/ui-egui/src/agent_chat/api_client.rsindex 38bc005796..88c38e39af 100644--- a/crates/ui-egui/src/agent_chat/api_client.rs+++ b/crates/ui-egui/src/agent_chat/api_client.rs@@ -643,6 +643,10 @@ pub struct ApiConfig {pub http: HttpFn,/// How long one model request may take, in seconds (the endpoint's setting).pub request_timeout_s: u64,+ /// The reasoning effort to send as `reasoning_effort`; empty sends nothing and the+ /// provider's own default applies. A set value wins over the `none` retry (#3817): that+ /// retry only runs when no effort was chosen.+ pub reasoning_effort: String,}enum Cmd {@@ -650,6 +654,7 @@ enum Cmd {NewChat,SetModel(String),SetRequestTimeout(u64),+ SetReasoningEffort(String),}pub struct ApiBackend {@@ -724,6 +729,11 @@ impl ChatBackend for ApiBackend {let _ = c.send(Cmd::SetRequestTimeout(secs));}}+ fn set_reasoning_effort(&mut self, effort: &str) {+ if let Some(c) = &self.cmds {+ let _ = c.send(Cmd::SetReasoningEffort(effort.to_string()));+ }+ }fn new_session(&mut self) {// A running turn is cancelled; the worker resets the history once it has ended.self.cancel.store(true, Ordering::Relaxed);@@ -800,6 +810,12 @@ impl Worker {Cmd::Prompt(parts) => self.turn(parts),Cmd::SetModel(m) => self.cfg.model = m,Cmd::SetRequestTimeout(secs) => self.cfg.request_timeout_s = secs,+ Cmd::SetReasoningEffort(effort) => {+ self.cfg.reasoning_effort = super::agents::reasoning_effort(&effort);+ // A new choice starts the refusal dance again: an earlier `none` answer was+ // the endpoint's, not the user's, and must not silently override the choice.+ self.no_reasoning.set(false);+ }Cmd::NewChat => {self.history.clear();// A new conversation gets a fresh Go session ID for routing and caching.@@ -980,6 +996,12 @@ impl Worker {self.history.len() != before}+ /// The reasoning effort the user chose for this endpoint, or `None` to send nothing and let+ /// the provider apply its own default.+ fn reasoning_effort(&self) -> Option<&str> {+ (!self.cfg.reasoning_effort.trim().is_empty()).then(|| self.cfg.reasoning_effort.trim())+ }+fn request(&self) -> Result<Reply, String> {// OpenCode Go serves one protocol per model family behind a single base URL.if self.cfg.protocol == Protocol::OpenAi && is_opencode_go(&self.cfg.base_url) {@@ -989,11 +1011,13 @@ impl Worker {let (status, v) = self.post(&body)?;// Some OpenAI models refuse function tools on this endpoint unless the reasoning effort is// "none" (HTTP 400 naming `reasoning_effort`): ask again once with it, and keep it for the- // next requests. Anthropic has no such parameter.+ // next requests. Anthropic has no such parameter. A reasoning effort the user chose wins:+ // the refusal is shown instead of being replaced silently (#10241).let refused = self.cfg.protocol == Protocol::OpenAi&& status == 400&& !self.tools.is_empty()&& !self.no_reasoning.get()+ && self.reasoning_effort().is_none()&& http_error(status, &v).contains("reasoning_effort");if refused {self.no_reasoning.set(true);@@ -1021,15 +1045,19 @@ impl Worker {let mut first_err: Option<String> = None;for protocol in order {let mut body = self.go_body(protocol);- if protocol == GoProtocol::Chat && !self.tools.is_empty() && self.no_reasoning.get() {+ if protocol == GoProtocol::Chat && !self.tools.is_empty() && self.no_reasoning.get() && self.reasoning_effort().is_none() {body["reasoning_effort"] = json!("none");}let (status, v) = self.go_post(protocol, &body)?;if protocol == GoProtocol::Chat {// As on plain OpenAI endpoints: ask again once with reasoning effort- // "none" when the refusal names it.- let refused =- status == 400 && !self.tools.is_empty() && !self.no_reasoning.get() && http_error(status, &v).contains("reasoning_effort");+ // "none" when the refusal names it — unless the user chose an effort, whose+ // refusal is shown instead (#10241).+ let refused = status == 400+ && !self.tools.is_empty()+ && !self.no_reasoning.get()+ && self.reasoning_effort().is_none()+ && http_error(status, &v).contains("reasoning_effort");if refused {self.no_reasoning.set(true);body["reasoning_effort"] = json!("none");@@ -1143,9 +1171,14 @@ impl Worker {messages.push(json!({"role": "system", "content": super::acp::SYSTEM_NOTE}));messages.extend(self.history.iter().cloned());let mut body = json!({"model": self.cfg.model, "messages": messages});+ if let Some(effort) = self.reasoning_effort() {+ // The user's choice goes out on every request, ahead of any `none` the+ // endpoint once asked for (#10241).+ body["reasoning_effort"] = json!(effort);+ }if !self.tools.is_empty() {body["tools"] = Value::Array(self.tools.clone());- if self.no_reasoning.get() {+ if self.no_reasoning.get() && self.reasoning_effort().is_none() {body["reasoning_effort"] = json!("none");}}@@ -1861,6 +1894,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();@@ -1911,6 +1945,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();@@ -1964,6 +1999,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();@@ -2010,6 +2046,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();@@ -2093,6 +2130,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),}}@@ -2166,6 +2204,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let mut b = ApiBackend::start(cfg, go_ctx()).unwrap();b.prompt(&[PromptPart::Text("hi".into())]);@@ -2484,6 +2523,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let mut b = ApiBackend::start(cfg, go_ctx()).unwrap();b.prompt(&[PromptPart::Text("hi".into())]);@@ -2556,6 +2596,7 @@ mod tests {key: None,http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();@@ -2585,6 +2626,7 @@ mod tests {key: Some("k".into()),http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };assert!(ApiBackend::start(cfg, ctx).is_err());@@ -2593,6 +2635,11 @@ mod tests {/// A worker with one function tool whose endpoint answers each POST with the next scripted/// (status, body); the requests it received are returned too.fn scripted_worker(answers: Vec<(u16, Value)>) -> (Worker, Arc<std::sync::Mutex<Vec<Value>>>) {+ scripted_worker_effort(answers, "")+ }++ /// [`scripted_worker`] with the endpoint's reasoning effort set (empty: send nothing).+ fn scripted_worker_effort(answers: Vec<(u16, Value)>, effort: &str) -> (Worker, Arc<std::sync::Mutex<Vec<Value>>>) {let answers = std::sync::Mutex::new(answers.into_iter().rev().collect::<Vec<_>>());let seen = Arc::new(std::sync::Mutex::new(Vec::<Value>::new()));let log = seen.clone();@@ -2609,6 +2656,7 @@ mod tests {key: Some("sk-secret".into()),http,request_timeout_s: 300,+ reasoning_effort: effort.to_string(),};let (events, _rx) = channel();let w = Worker {@@ -2660,6 +2708,37 @@ mod tests {assert_eq!(seen.lock().unwrap().len(), 1);}+ /// A reasoning effort the user chose goes out as `reasoning_effort` on every request; empty+ /// sends nothing, so existing agents are untouched (#10241).+ #[test]+ fn a_chosen_reasoning_effort_goes_out_on_every_request() {+ let ok = json!({"choices": [{"message": {"role": "assistant", "content": "Done."}}]});+ let (w, seen) = scripted_worker_effort(vec![(200, ok.clone()), (200, ok.clone())], "high");+ assert_eq!(w.request().unwrap().assistant, ok["choices"][0]["message"]);+ assert_eq!(w.request().unwrap().assistant, ok["choices"][0]["message"]);+ let sent = seen.lock().unwrap();+ assert_eq!(sent.len(), 2);+ assert_eq!(sent[0]["reasoning_effort"], "high");+ assert_eq!(sent[1]["reasoning_effort"], "high");+ drop(sent);+ // Empty effort: nothing is sent at all.+ let (w, seen) = scripted_worker(vec![(200, ok)]);+ assert!(w.request().is_ok());+ assert!(seen.lock().unwrap()[0].get("reasoning_effort").is_none());+ }++ /// A chosen effort wins over the #3817 `none` retry: the endpoint's refusal of the effort is+ /// shown to the user after exactly one request, never silently replaced by `none` (#10241).+ #[test]+ fn a_chosen_reasoning_effort_wins_over_the_none_retry() {+ let (w, seen) = scripted_worker_effort(vec![refusal()], "max");+ let e = w.request().unwrap_err();+ assert!(e.starts_with("HTTP 400") && e.contains("reasoning_effort"), "{e}");+ let sent = seen.lock().unwrap();+ assert_eq!(sent.len(), 1, "the refusal is shown, not replayed with none");+ assert_eq!(sent[0]["reasoning_effort"], "max");+ }+#[test]fn mcp_tools_become_anthropic_tools_without_crash_reports() {let list = json!({"tools": [@@ -2742,6 +2821,7 @@ mod tests {key: Some("sk-secret".into()),http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();@@ -2791,6 +2871,7 @@ mod tests {key: Some("sk-secret".into()),http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();@@ -2841,6 +2922,7 @@ mod tests {key: Some("sk-secret".into()),http,request_timeout_s: 300,+ reasoning_effort: String::new(),};let ctx = StartContext { cwd: std::env::temp_dir(), bridge: None, tools: None, wake: Box::new(|| {}) };let mut b = ApiBackend::start(cfg, ctx).unwrap();diff --git a/crates/ui-egui/src/agent_chat/backend.rs b/crates/ui-egui/src/agent_chat/backend.rsindex afa1c44e9e..c7976a8d51 100644--- a/crates/ui-egui/src/agent_chat/backend.rs+++ b/crates/ui-egui/src/agent_chat/backend.rs@@ -147,6 +147,8 @@ pub trait ChatBackend {fn set_mode(&mut self, _mode: &str) {}/// An endpoint's new request timeout, in seconds, from the next request on.fn set_request_timeout(&mut self, _secs: u64) {}+ /// An endpoint's new reasoning effort (empty: send nothing), from the next request on.+ fn set_reasoning_effort(&mut self, _effort: &str) {}fn set_config_option(&mut self, _id: &str, _value: &str) {}/// Its process, for status and tests.fn pid(&self) -> Option<u32> {diff --git a/crates/ui-egui/src/agent_chat/mod.rs b/crates/ui-egui/src/agent_chat/mod.rsindex 8c9eafb681..b1554a06c8 100644--- a/crates/ui-egui/src/agent_chat/mod.rs+++ b/crates/ui-egui/src/agent_chat/mod.rs@@ -967,6 +967,7 @@ pub fn connect(app: &mut SolveApp, ctx: &egui::Context) {key,http,request_timeout_s: entry.request_timeout_s,+ reasoning_effort: entry.reasoning_effort.clone(),},start,)diff --git a/crates/ui-egui/src/agent_chat/settings.rs b/crates/ui-egui/src/agent_chat/settings.rsindex 1dd6b99540..8b406642f5 100644--- a/crates/ui-egui/src/agent_chat/settings.rs+++ b/crates/ui-egui/src/agent_chat/settings.rs@@ -30,6 +30,8 @@ pub struct AddState {pub key: String,/// Seconds one model request may take.pub request_timeout_s: u64,+ /// Optional reasoning effort sent as `reasoning_effort`; empty sends nothing.+ pub reasoning_effort: String,pub error: Option<String>,/// Editing this added agent (its id) instead of adding a new one.pub editing: Option<String>,@@ -181,6 +183,7 @@ pub fn open_edit(app: &mut SolveApp, id: &str) -> bool {let mut s = AddState {name: c.name.clone(),request_timeout_s: c.request_timeout_s.clamp(agents::MIN_REQUEST_TIMEOUT_S, agents::MAX_REQUEST_TIMEOUT_S),+ reasoning_effort: c.reasoning_effort.clone(),editing: Some(c.id.clone()),..Default::default()};@@ -259,6 +262,13 @@ fn timeout_field(ui: &mut egui::Ui, secs: &mut u64, handle: &str) -> bool {r.changed()}+/// The free-text reasoning effort field with its hover hint; true when the text changed.+fn effort_field(ui: &mut egui::Ui, effort: &mut String) -> bool {+ ui_kit::cell_editor(ui, ui.id().with("ai_reasoning_effort"), effort, tr("ui.ai_reasoning_effort_field_hint"), false)+ .on_hover_text(tr("ui.ai_reasoning_effort_hint"))+ .changed()+}+fn test_line(ui: &mut egui::Ui, test: &Option<&Test>) {match test {Some(Test::Running(_)) => {@@ -444,6 +454,7 @@ fn agents_section(app: &mut SolveApp, ui: &mut egui::Ui) {let mut test: Option<agents::Entry> = None;let mut edit: Option<String> = None;let mut retimed: Option<(String, u64)> = None;+ let mut reeffort: Option<(String, String)> = None;let t = crate::theme::Tokens::get();ui_kit::settings_section(ui, "agents", tr("ui.ai_agents"), |ui| {if app.agent_chat.detecting.is_some() {@@ -504,8 +515,11 @@ fn agents_section(app: &mut SolveApp, ui: &mut egui::Ui) {}});ui_kit::settings_short_note(ui, &entry.detail());- // Wide enough for an endpoint's "Request timeout" too, so both rows line up.- let label_w = (t.form_label_width + t.space_16).max(ui_kit::ContentWidth::label(ui, tr("ui.ai_request_timeout")) + t.space_16);+ // Wide enough for an endpoint's "Request timeout" or "Reasoning effort" too,+ // so all rows line up.+ let label_w = (t.form_label_width + t.space_16)+ .max(ui_kit::ContentWidth::label(ui, tr("ui.ai_request_timeout")) + t.space_16)+ .max(ui_kit::ContentWidth::label(ui, tr("ui.ai_reasoning_effort")) + t.space_16);ui_kit::settings_form(ui, label_w, |ui| {ui_kit::row(ui, tr("ui.ai_permissions"), |ui| {let current = app.preferences.agent_permissions.get(&entry.id).copied();@@ -543,6 +557,14 @@ fn agents_section(app: &mut SolveApp, ui: &mut egui::Ui) {retimed = Some((entry.id.clone(), secs));}});+ ui_kit::row(ui, tr("ui.ai_reasoning_effort"), |ui| {+ let mut effort = c.reasoning_effort.clone();+ if effort_field(ui, &mut effort) {+ let effort = agents::reasoning_effort(&effort);+ c.reasoning_effort = effort.clone();+ reeffort = Some((entry.id.clone(), effort));+ }+ });});}if app.preferences.agent_permissions.get(&entry.id) == Some(&Mode::All) {@@ -579,6 +601,13 @@ fn agents_section(app: &mut SolveApp, ui: &mut egui::Ui) {{b.set_request_timeout(secs);}+ // A new reasoning effort likewise takes effect from the next request on.+ if let Some((id, effort)) = reeffort+ && app.agent_chat.running_id == id+ && let Some(b) = app.agent_chat.backend.as_mut()+ {+ b.set_reasoning_effort(&effort);+ }if let Some(id) = remove {app.agent_chat.login_results.remove(&id);app.agent_chat.settings.tests.remove(&id);@@ -727,6 +756,9 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {ui_kit::row(ui, tr("ui.ai_request_timeout"), |ui| {timeout_field(ui, &mut s.request_timeout_s, "ai_add:request_timeout");});+ ui_kit::row(ui, tr("ui.ai_reasoning_effort"), |ui| {+ effort_field(ui, &mut s.reasoning_effort);+ });ui_kit::row(ui, tr("ui.ai_key"), |ui| {ui.add_enabled_ui(has_keychain, |ui| {let hint = tr(if s.saved_key { "ui.ai_key_keep_hint" } else { "ui.ai_key_hint" });@@ -766,6 +798,7 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {model: s.model.trim().to_string(),key: false,request_timeout_s: s.request_timeout_s,+ reasoning_effort: agents::reasoning_effort(&s.reasoning_effort),problem: None,install: "",};@@ -829,6 +862,7 @@ fn add_agent(app: &mut SolveApp) -> Result<(), String> {c.base_url = agents::normalize_url(&s.base_url)?;c.model = s.model.trim().to_string();c.request_timeout_s = s.request_timeout_s.clamp(agents::MIN_REQUEST_TIMEOUT_S, agents::MAX_REQUEST_TIMEOUT_S);+ c.reasoning_effort = agents::reasoning_effort(&s.reasoning_effort);if c.model.is_empty() {return Err(tr("ui.ai_need_model").to_string());}@@ -870,6 +904,7 @@ fn add_agent(app: &mut SolveApp) -> Result<(), String> {*old = c;let id = old.id.clone();let secs = old.request_timeout_s;+ let effort = old.reasoning_effort.clone();// A new command, endpoint or key has not been tested or signed in yet.app.agent_chat.settings.tests.remove(&id);app.agent_chat.login_results.remove(&id);@@ -879,6 +914,7 @@ fn add_agent(app: &mut SolveApp) -> Result<(), String> {&& let Some(b) = app.agent_chat.backend.as_mut(){b.set_request_timeout(secs);+ b.set_reasoning_effort(&effort);}}}@@ -1069,6 +1105,7 @@ mod card_tests {model: "model-a".into(),key: true,request_timeout_s: 600,+ reasoning_effort: "high".into(),..Default::default()});assert!(open_edit(&mut h.app, "api-1"));@@ -1079,11 +1116,13 @@ mod card_tests {assert_eq!((s.kind, s.protocol), (AddKind::Api, Protocol::OpenAi));assert_eq!(agents::presets(Protocol::OpenAi).get(s.preset).map(|p| p.name), Some("OpenAI"));assert_eq!((s.base_url.as_str(), s.model.as_str(), s.request_timeout_s), ("https://api.openai.com/v1", "model-a", 600));+ assert_eq!(s.reasoning_effort, "high", "the chosen effort comes back into the dialog");}h.app.agent_chat.settings.add.as_mut().unwrap().model = "model-b".into();add_agent(&mut h.app).unwrap();let saved = &h.app.preferences.agents[0];assert_eq!((saved.id.as_str(), saved.model.as_str(), saved.key, saved.request_timeout_s), ("api-1", "model-b", true, 600));+ assert_eq!(saved.reasoning_effort, "high", "the effort survives an edit");assert_eq!(keys.get("api-1").unwrap().as_deref(), Some("test-key-1"), "an empty field keeps the key");// A kept key does not go to a plain-HTTP address elsewhere.assert!(open_edit(&mut h.app, "api-1"));diff --git a/docs/agent-chat.md b/docs/agent-chat.mdindex a00afee2a9..0dd8cbded4 100644--- a/docs/agent-chat.md+++ b/docs/agent-chat.md@@ -265,7 +265,12 @@ Grok Build also supports `XAI_API_KEY` for users who choose API authentication.take: 300 s by default, from 30 s to an hour. A slow local model (a large model on modesthardware, or a long message with many tool results) may need more; raise it here or in theendpoint's entry under **Agents**, where a change applies from the next request. A request that- runs out of time ends the message with the limit it hit and where to raise it.+ runs out of time ends the message with the limit it hit and where to raise it. **Reasoning+ effort** is optional and empty by default: nothing is sent and the provider's own default+ applies. When set, the value goes out as `reasoning_effort` on each `/chat/completions`+ request; accepted values differ per provider and model (for example `low`, `high` or `max`).+ A value you set is never replaced by SolidCraft: if the endpoint refuses it, the refusal is+ shown instead of being retried with `none`.**Edit** on an agent you added opens the same dialog filled with its name and command, or itsprotocol, endpoint, model and request timeout, and **Save** changes it in place: it keeps its id,