SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Assistant: say so when a turn ends without using SolidCraft's tools (#4846) (#5188)
raykholoffbeb42b5c36
diff --git a/assets/locales/pending/assistant-no-tool-call.json b/assets/locales/pending/assistant-no-tool-call.jsonnew file mode 100644index 0000000000..84674e932f--- /dev/null+++ b/assets/locales/pending/assistant-no-tool-call.json@@ -0,0 +1,5 @@+{+ "en": { "ui.agent_chat_no_tool_call": "The model didn't use SolidCraft's tools, so the design wasn't changed. Choose a model that supports tool calling; see Local models in the agent chat guide." },+ "ja": { "ui.agent_chat_no_tool_call": "モデルが SolidCraft のツールを使わなかったため、デザインは変更されませんでした。ツール呼び出しに対応したモデルを選んでください。エージェントチャットのガイドの「ローカルモデル」を参照してください。" },+ "zh": { "ui.agent_chat_no_tool_call": "模型没有使用 SolidCraft 的工具,因此设计没有更改。请选择支持工具调用的模型;参见智能体聊天指南中的“本地模型”。" }+}diff --git a/crates/ui-egui/src/agent_chat/api_client.rs b/crates/ui-egui/src/agent_chat/api_client.rsindex 58e75f1ac2..e34217782f 100644--- a/crates/ui-egui/src/agent_chat/api_client.rs+++ b/crates/ui-egui/src/agent_chat/api_client.rs@@ -183,6 +183,7 @@ impl Worker {if let Err(e) = self.start_mcp() {self.emit(Event::Error(e));}+ self.emit(Event::ToolsAvailable(!self.tools.is_empty()));self.emit(Event::Ready { agent: format!("{} · {}", self.cfg.name, self.cfg.model), images: true });// The endpoint's models for the picker; an endpoint that does not list them shows none.if let Ok(list) = self.model_list() {@@ -939,7 +940,8 @@ mod tests {events.extend(b.poll());std::thread::sleep(Duration::from_millis(10));}- assert!(matches!(events.first(), Some(Event::Ready { .. })), "{events:?}");+ assert_eq!(events.first(), Some(&Event::ToolsAvailable(false)));+ assert!(events.iter().any(|e| matches!(e, Event::Ready { .. })), "{events:?}");assert!(events.iter().any(|e| matches!(e, Event::Tool { status: Some(ToolStatus::Failed), .. })), "{events:?}");assert!(events.iter().any(|e| matches!(e, Event::Text { text, .. } if text == "Done.")), "{events:?}");assert!(matches!(events.last(), Some(Event::TurnEnded { reason }) if reason.is_empty()), "{events:?}");@@ -1336,7 +1338,8 @@ mod tests {events.extend(b.poll());std::thread::sleep(Duration::from_millis(10));}- assert!(matches!(events.first(), Some(Event::Ready { .. })), "{events:?}");+ assert_eq!(events.first(), Some(&Event::ToolsAvailable(false)));+ assert!(events.iter().any(|e| matches!(e, Event::Ready { .. })), "{events:?}");assert!(events.iter().any(|e| matches!(e, Event::Tool { status: Some(ToolStatus::Failed), .. })), "{events:?}");assert!(events.iter().any(|e| matches!(e, Event::Text { text, .. } if text == "Done.")), "{events:?}");assert!(matches!(events.last(), Some(Event::TurnEnded { reason }) if reason.is_empty()), "{events:?}");diff --git a/crates/ui-egui/src/agent_chat/backend.rs b/crates/ui-egui/src/agent_chat/backend.rsindex b4d1375b10..7a4b3ac3e2 100644--- a/crates/ui-egui/src/agent_chat/backend.rs+++ b/crates/ui-egui/src/agent_chat/backend.rs@@ -34,6 +34,8 @@ pub enum PromptPart {pub enum Event {/// Whether the agent takes documents (PDFs) in a message; sent before [`Event::Ready`].Documents(bool),+ /// Whether SolidCraft tools were offered by the backend.+ ToolsAvailable(bool),/// Ready for a message. `agent`: its name and version; `images`: it takes pictures.Ready { agent: String, images: bool },/// Text it streams (`thought`: its reasoning, shown dimmed).diff --git a/crates/ui-egui/src/agent_chat/mod.rs b/crates/ui-egui/src/agent_chat/mod.rsindex 10be0d4a94..144bb2b5e7 100644--- a/crates/ui-egui/src/agent_chat/mod.rs+++ b/crates/ui-egui/src/agent_chat/mod.rs@@ -253,6 +253,10 @@ struct Turn {changes: u32,requests: u32,limit_told: bool,+ tools_available: bool,+ tool_called: bool,+ replied: bool,+ edit_requested: bool,label: String,}@@ -390,6 +394,9 @@ pub struct AgentChat {running_endpoint: String,backend: Option<Box<dyn ChatBackend>>,turn: Option<Turn>,+ tools_available: Option<bool>,+ /// The latest completed turn's notice; older notices remain in the transcript.+ turn_warning: Option<String>,held: Vec<Held>,next_approval: u64,/// The chat's control endpoint: the port, and its requests.@@ -564,6 +571,7 @@ impl AgentChat {fn on_event(&mut self, e: Event) -> Option<Outcome> {match e {Event::Documents(documents) => self.documents = documents,+ Event::ToolsAvailable(available) => self.tools_available = Some(available),Event::Ready { agent, images } => {self.agent = agent;self.images = images;@@ -579,6 +587,12 @@ impl AgentChat {}}Event::Text { thought, text } => {+ if !thought+ && !text.trim().is_empty()+ && let Some(turn) = self.turn.as_mut()+ {+ turn.replied = true;+ }if let Some(Item::Agent { thought: t, text: last }) = self.items.last_mut()&& *t == thought{@@ -588,6 +602,9 @@ impl AgentChat {}}Event::Tool { id, title, kind, status, output } => {+ if let Some(turn) = self.turn.as_mut() {+ turn.tool_called = true;+ }let existing = self.items.iter_mut().rev().find(|i| matches!(i, Item::Tool { id: x, .. } if *x == id));if let Some(Item::Tool { title: t, kind: k, status: s, output: o, .. }) = existing {if let Some(v) = title {@@ -822,6 +839,7 @@ pub fn connect(app: &mut SolveApp, ctx: &egui::Context) {chat.notice(tr("ui.agent_chat_no_cli"), true);}let bridge = cli.zip(chat.tools_port).map(|(cli, port)| acp::McpBridge { cli, port });+ chat.tools_available = Some(bridge.is_some());let wake = ctx.clone();let start = backend::StartContext { cwd: working_dir(), bridge, tools: chat.tools_tx.clone(), wake: Box::new(move || wake.request_repaint()) };let started: Result<Box<dyn ChatBackend>, String> = match entry.kind {@@ -1106,6 +1124,7 @@ pub fn new_chat(app: &mut SolveApp) {let chat = &mut app.agent_chat;chat.confirm_new = false;chat.items.clear();+ chat.turn_warning = None;chat.gallery = None;chat.picked.clear();chat.picked_context = Context::default();@@ -1188,6 +1207,7 @@ fn start_turn_with(app: &mut SolveApp, text: String, image: bool, at: Option<usi// The undo step is named after the message, or its first file when it has no words.let first_line = text.lines().find(|l| !l.trim().is_empty()).or_else(|| files.first().map(|f| f.name.as_str())).unwrap_or("");let label: String = first_line.chars().take(48).collect();+ app.agent_chat.turn_warning = None;app.agent_chat.turn = Some(Turn {active: Arc::new(std::sync::atomic::AtomicBool::new(true)),start_doc: app.session.doc.clone(),@@ -1196,6 +1216,10 @@ fn start_turn_with(app: &mut SolveApp, text: String, image: bool, at: Option<usirequests: 0,limit_told: false,label,+ tools_available: app.agent_chat.tools_available.unwrap_or(app.agent_chat.tools_port.is_some()),+ tool_called: false,+ replied: false,+ edit_requested: requests_edit(&text),});app.agent_chat.last = Some((text, image, at, files));app.agent_chat.state = Some(State::Busy);@@ -1408,6 +1432,24 @@ fn approve_with(app: &mut SolveApp, id: u64, allow: bool, why: &str) {}}+/// Recognise only explicit English edit requests; informational questions stay quiet.+/// This checks the user's opening words, never interprets the model's prose as a call.+fn requests_edit(text: &str) -> bool {+ let opening: String = text.trim().chars().take(160).collect::<String>().to_ascii_lowercase();+ let mut words = opening.as_str();+ for prefix in ["please ", "can you ", "could you ", "would you ", "please "] {+ if let Some(rest) = words.strip_prefix(prefix) {+ words = rest;+ }+ }+ [+ "add", "create", "make", "change", "rename", "move", "rotate", "delete", "remove", "sketch", "extrude", "round", "fillet", "chamfer",+ "scale", "cut", "drill",+ ]+ .iter()+ .any(|verb| words.strip_prefix(*verb).is_some_and(|rest| rest.starts_with(char::is_whitespace)))+}+/// The message is answered: its changes become one undo step, and what still waits is declined.fn end_turn(app: &mut SolveApp) {decline_all(app, "the message ended");@@ -1418,6 +1460,20 @@ fn finish_turn(chat: &mut AgentChat, session: &mut solidcraft_engine::Session) {let Some(turn) = chat.turn.take() else { return };turn.active.store(false, std::sync::atomic::Ordering::Relaxed);let steps = merge_undo(&mut session.undo, &turn.start_doc, turn.start_undo, &trf("ui.agent_chat_undo_label", &[("message", &turn.label)]));+ if chat.ended.as_deref() == Some("")+ && !chat.stopped+ && turn.tools_available+ && !turn.tool_called+ && turn.requests == 0+ && turn.changes == 0+ && steps == 0+ && Arc::ptr_eq(&session.doc, &turn.start_doc)+ && (!turn.replied || turn.edit_requested)+ {+ let warning = tr("ui.agent_chat_no_tool_call").to_string();+ chat.turn_warning = Some(warning.clone());+ chat.notice(warning, false);+ }if steps > 0 {let doc = session.doc.clone();chat.push(Item::Changes { steps, doc, undone: false });@@ -1990,6 +2046,7 @@ pub fn status(app: &SolveApp) -> Value {"loading": c.loading.iter().map(|f| f.name.clone()).collect::<Vec<_>>(),"stopped": c.stopped,"turn": c.turn.as_ref().map(|t| json!({"changes": t.changes, "requests": t.requests})),+ "turnWarning": c.turn_warning,"detection": detection,"items": items,})diff --git a/crates/ui-egui/src/agent_chat/panel.rs b/crates/ui-egui/src/agent_chat/panel.rsindex 7e4ebd30b0..d1998b33b0 100644--- a/crates/ui-egui/src/agent_chat/panel.rs+++ b/crates/ui-egui/src/agent_chat/panel.rs@@ -1472,7 +1472,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {}Item::Notice { text, error } => {ui_kit::assistant_banner(ui, if *error { ui_kit::AssistantTone::Error } else { ui_kit::AssistantTone::Neutral }, |ui| {- ui.label(RichText::new(text).color(if *error { t.error } else { t.text_dim }));+ ui.add(egui::Label::new(RichText::new(text).color(if *error { t.error } else { t.text_dim })).wrap());});}}diff --git a/crates/ui-egui/src/agent_chat/tests.rs b/crates/ui-egui/src/agent_chat/tests.rsindex 04a0421d54..6338f6c3d5 100644--- a/crates/ui-egui/src/agent_chat/tests.rs+++ b/crates/ui-egui/src/agent_chat/tests.rs@@ -2382,3 +2382,68 @@ fn add_agent_takes_a_request_timeout_and_the_state_reports_it() {control(&mut app, &ctx, &json!({"add_agent": {"id": "acp", "name": "A", "command": "x --acp"}})).unwrap();assert_eq!(timeout(&mut app, "acp"), Some(Value::Null), "only endpoints have a request timeout");}++#[test]+fn no_tool_turn_reports_empty_reply_and_unperformed_edit() {+ for (prompt, reply) in [+ ("Hello", ""),+ ("Hello", " "),+ ("Make a box", "Here is how to make a box."),+ ("Can you rename the body?", "I cannot rename bodies."),+ ("Could you please make a change to the current shape", "Here is the command."),+ ("Sketch a rectangle", r#"{"name":"batch","arguments":{"commands":[]}}"#),+ ] {+ let (mut app, _, _) = app_with_script();+ app.agent_chat.tools_port = Some(12345);+ start_turn(&mut app, prompt.into(), false, None, vec![]);+ if !reply.is_empty() {+ app.agent_chat.on_event(Event::Text { thought: false, text: reply.into() });+ }+ app.agent_chat.on_event(Event::TurnEnded { reason: String::new() });+ end_turn(&mut app);+ let expected = tr("ui.agent_chat_no_tool_call");+ assert!(app.agent_chat.items.iter().any(|i| matches!(i, Item::Notice { text, error: false } if text == expected)), "{prompt}");+ assert_eq!(status(&app)["turnWarning"], expected);+ assert!(app.session.undo.is_empty());+ start_turn(&mut app, "What is a fillet?".into(), false, None, vec![]);+ assert!(status(&app)["turnWarning"].is_null());+ assert!(app.agent_chat.items.iter().any(|i| matches!(i, Item::Notice { text, .. } if text == expected)));+ new_chat(&mut app);+ assert!(status(&app)["turnWarning"].is_null());+ assert!(app.agent_chat.items.is_empty());+ }+}++#[test]+fn no_tool_turn_warning_does_not_follow_a_tool_call() {+ let (mut app, _, _) = app_with_script();+ app.agent_chat.tools_port = Some(12345);+ start_turn(&mut app, "Make a box".into(), false, None, vec![]);+ app.agent_chat.on_event(Event::Tool { id: "t".into(), title: Some("batch".into()), kind: None, status: Some(ToolStatus::Failed), output: None });+ app.agent_chat.on_event(Event::TurnEnded { reason: String::new() });+ end_turn(&mut app);+ assert!(status(&app).get("turnWarning").is_some());+ assert!(status(&app)["turnWarning"].is_null());+ assert!(!app.agent_chat.items.iter().any(|i| matches!(i, Item::Notice { .. })));+}++#[test]+fn no_tool_turn_warning_leaves_answers_and_incomplete_turns_quiet() {+ for (prompt, reply, reason, tools) in [+ ("What is a fillet?", "A fillet rounds an edge.", "", true),+ ("How do I make a box?", "Use the Box command.", "", true),+ ("Make a box", "", "cancelled", true),+ ("Make a box", "", "error", true),+ ("Make a box", "", "", false),+ ] {+ let (mut app, _, _) = app_with_script();+ app.agent_chat.tools_port = tools.then_some(12345);+ start_turn(&mut app, prompt.into(), false, None, vec![]);+ app.agent_chat.on_event(Event::Text { thought: false, text: reply.into() });+ app.agent_chat.on_event(Event::TurnEnded { reason: reason.into() });+ end_turn(&mut app);+ assert!(status(&app).get("turnWarning").is_some());+ assert!(status(&app)["turnWarning"].is_null(), "{prompt}: {reason}");+ assert!(!app.agent_chat.items.iter().any(|i| matches!(i, Item::Notice { text, .. } if text == tr("ui.agent_chat_no_tool_call"))));+ }+}diff --git a/docs/agent-chat.md b/docs/agent-chat.mdindex 57933574ee..6cf8b06ebb 100644--- a/docs/agent-chat.md+++ b/docs/agent-chat.md@@ -231,6 +231,18 @@ model, with a limit of 128 entries. SolidCraft recognises Ollama through `/api/vendpoint's origin or the Ollama preset. Failed checks and older servers without a capabilitiesfield show no warning. The check never blocks sending a message.+### Local models++Choose a model that supports native tool calling to read or change the design. With Ollama,+look for `tools` in the model's capabilities; a model that only supports chat cannot operate+SolidCraft. Other OpenAI-compatible endpoints also need a model with native tool support.++If tools were available but a completed turn made no tool calls or changes, the panel shows a+short notice when the reply was empty, or when an explicit edit request received only text.+Ordinary answers to questions do not show it. Edit requests are recognised conservatively from+English opening words such as “make”, “rename”, or “can you move”; other phrasing may stay quiet.+Cancelled and failed turns keep their existing messages. Text describing a call is never run.+### An agent inside WSL (Windows)An agent installed inside WSL keeps its own settings, skills and sign-in there. Add it as adiff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 4539c6081e..f8f7379b4d 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -253,7 +253,7 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.| `engine.execute` → `browser.expand_all` | `path?`: occurrence ids; `component?`: id; omit both for the whole tree | Open every Browser row under that scope, including folders that start closed (Origin, Named Views, Features). Display only: not saved in the design, not an undo step. || `engine.execute` → `browser.collapse_all` | same | Close those rows. The design row stays open when the whole tree is collapsed. || `engine.execute` → `view.history_layout` | `width?`, `dock?`: `bottom`, `left`, `under_browser`, `collapsed?` | Resize/dock the history without opening a dialog or changing the design. Contents respond to measured width; browser-stacked history shares its width and splits height equally. One folded header gives the expanded card the rest; two folded headers stay at the top. |-| `ui.agent_chat` | `features?`, `toolbar_button?`, `permissions?` (`ask`, `edits`, `all`), `add_agent?` ({`name`, `kind`: `acp`, `api` or `anthropic` (`api` is OpenAI-compatible, `anthropic` Anthropic-compatible), `command` or `base_url` + `model` + `request_timeout_s?` (seconds one model request may take, 300 by default, rounded and clamped to 30 to 3600)}; no keys), `add_dialog?` (`installed`, `custom`, `api`, `anthropic`, or `false` to close), `default_agent?`, `agent?` (the conversation's agent, by id), `mode?` (the agent's own mode), `provider?` (which provider's models the model picker lists, when they come from several), `model?` (one of its models), `open?`, `side?` (`left`, `right`), `minimized?`, `popped?` (in its own window), `width?`, `picker?`, `refresh?`, `connect?`, `stop?`, `attach?`: a file's path (a picture, a text file or a CAD file, for the next message; CAD files are imported at once), `remove_file?` (index of a file on the next message), `send?`: text (files alone make a message too), `attach_view?`, `attach_selection?`, `pick?` (true: open the context picker), `permission?`: an option id or `"cancel"` (the newest question of the agent's own), `approve?`: true, false or `"always"` (the oldest request held for Allow/Deny), `cancel?` (Stop: the queue stays), `send_now?` (stop the running step, then send the queued messages), `remove_pending?` (index), `new_chat?` (clear the chat, new session), `undo?` (the last message's changes) | the chat's state: `features`, `agents` (found and added), `currentAgent`, `state` (off, starting, ready, busy, auth, exited), `popped`, `window` (its place and size), `agent`, `modes`, `mode`, `models`, `model`, `modelWarning` (the model capability warning text, or `null` when unknown or tool support is reported; checked asynchronously and never blocks sending), `providers` (`name` and `count` of each, empty with one provider), `provider` (the one listed), `authMethods`, `toolsPort`, `pid`, `waiting`, `turn`, `pending` (queued messages, with their `files`), `attachments` (the files on the next message, by name), `loading` (pictures still being read for it, by name), `stopped`, `detection` and the conversation (`items`). With `features` off only the settings apply. Desktop only; see [Agent chat](agent-chat.md) |+| `ui.agent_chat` | `features?`, `toolbar_button?`, `permissions?` (`ask`, `edits`, `all`), `add_agent?` ({`name`, `kind`: `acp`, `api` or `anthropic` (`api` is OpenAI-compatible, `anthropic` Anthropic-compatible), `command` or `base_url` + `model` + `request_timeout_s?` (seconds one model request may take, 300 by default, rounded and clamped to 30 to 3600)}; no keys), `add_dialog?` (`installed`, `custom`, `api`, `anthropic`, or `false` to close), `default_agent?`, `agent?` (the conversation's agent, by id), `mode?` (the agent's own mode), `provider?` (which provider's models the model picker lists, when they come from several), `model?` (one of its models), `open?`, `side?` (`left`, `right`), `minimized?`, `popped?` (in its own window), `width?`, `picker?`, `refresh?`, `connect?`, `stop?`, `attach?`: a file's path (a picture, a text file or a CAD file, for the next message; CAD files are imported at once), `remove_file?` (index of a file on the next message), `send?`: text (files alone make a message too), `attach_view?`, `attach_selection?`, `pick?` (true: open the context picker), `permission?`: an option id or `"cancel"` (the newest question of the agent's own), `approve?`: true, false or `"always"` (the oldest request held for Allow/Deny), `cancel?` (Stop: the queue stays), `send_now?` (stop the running step, then send the queued messages), `remove_pending?` (index), `new_chat?` (clear the chat, new session), `undo?` (the last message's changes) | the chat's state: `features`, `agents` (found and added), `currentAgent`, `state` (off, starting, ready, busy, auth, exited), `popped`, `window` (its place and size), `agent`, `modes`, `mode`, `models`, `model`, `modelWarning` (the model capability warning text, or `null` when unknown or tool support is reported; checked asynchronously and never blocks sending), `turnWarning` (the latest completed turn's no-tool notice, otherwise `null`; cleared on the next turn or new chat), `providers` (`name` and `count` of each, empty with one provider), `provider` (the one listed), `authMethods`, `toolsPort`, `pid`, `waiting`, `turn`, `pending` (queued messages, with their `files`), `attachments` (the files on the next message, by name), `loading` (pictures still being read for it, by name), `stopped`, `detection` and the conversation (`items`). With `features` off only the settings apply. Desktop only; see [Agent chat](agent-chat.md) || `ui.resize` | `width`, `height` | || `app.quit` | `force?` (quit without asking about unsaved designs) | `quitting` (the window closes), `asking` (a "save changes?" prompt is open) |