From f4f209d650b5927db60645f1de3b18d61f52c82d Mon Sep 17 00:00:00 2001 From: iz0eyj Date: Wed, 25 Nov 2026 18:47:56 +0100 Subject: [PATCH] Remove the tool toggle: tools are always on, the agent turn is the only GUI path --- README.md | 4 +-- web/assets/app.css | 1 - web/assets/app.js | 84 +++------------------------------------------- web/index.html | 1 - 4 files changed, 6 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index b1e9ba9..ce380f3 100644 --- a/README.md +++ b/README.md @@ -157,8 +157,8 @@ copied into `data/` once on first run (the original is left in place). ## Agent mode -The GUI model can **act**, not just chat. Tools are **on by default** (the 🤖 button -toggles them): the framework is meant to act, not just chat. The agent has a single +The GUI model can **act**, not just chat. Tools are **always on** — there is no +toggle, because the framework could not function without them. The agent has a single universal tool, **`shell_exec`** (a shell is universal: file ops, programs, system inspection, web via curl, git, …). A bounded server-side loop drives `model → shell_exec → result → model → … → final answer`, persisting the whole diff --git a/web/assets/app.css b/web/assets/app.css index 27960e9..24c7cb8 100644 --- a/web/assets/app.css +++ b/web/assets/app.css @@ -161,7 +161,6 @@ details.thinking .reasoning { font-size: 0.82rem; background: var(--bg); border-radius: 8px; padding: 8px; } .tool-out:empty { display: none; } -#agent-toggle.active { background: var(--accent); border-color: var(--accent); color: #fff; } /* ---- Composer ---- */ #composer { diff --git a/web/assets/app.js b/web/assets/app.js index e7ebdec..68ba53a 100644 --- a/web/assets/app.js +++ b/web/assets/app.js @@ -5,7 +5,7 @@ const $ = (sel) => document.querySelector(sel); -const state = { sessions: [], current: null, busy: false, agent: true, attachments: [] }; +const state = { sessions: [], current: null, busy: false, attachments: [] }; // ---- i18n: new user-facing strings go through t(key, params) -------------- // Catalogs are served at /assets/locales/.json; language follows the @@ -51,35 +51,6 @@ async function sendJSON(url, method, body) { return r.status === 204 ? null : r.json(); } -// Stream a chat turn, invoking onDelta for each SSE chunk. -async function streamChat(id, content, attachments, onDelta) { - const r = await fetch(`/api/sessions/${id}/chat`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ content, stream: true, attachments }), - }); - if (!r.ok) throw new Error(await r.text()); - const reader = r.body.getReader(); - const dec = new TextDecoder(); - let buf = ""; - for (;;) { - const { done, value } = await reader.read(); - if (done) break; - buf += dec.decode(value, { stream: true }); - let idx; - while ((idx = buf.indexOf("\n\n")) >= 0) { - const block = buf.slice(0, idx); - buf = buf.slice(idx + 2); - for (const line of block.split("\n")) { - if (!line.startsWith("data:")) continue; - const data = line.slice(5).trim(); - if (data === "[DONE]") return; - try { onDelta(JSON.parse(data)); } catch { /* ignore partial */ } - } - } - } -} - // ---- DOM builders --------------------------------------------------------- function el(tag, cls, text) { const n = document.createElement(tag); @@ -342,8 +313,7 @@ async function sendMessage() { const ids = attachments.map((a) => a.id); try { - if (state.agent) await agentTurn(content, t, ids); - else await chatTurn(content, t, ids); + await agentTurn(content, t, ids); state.sessions = await getJSON("/api/sessions"); renderSessions(); } catch (e) { @@ -356,44 +326,8 @@ async function sendMessage() { } } -// Plain chat: stream OpenAI chunks into a live assistant bubble. -async function chatTurn(content, t, attachments) { - const wrap = el("div", "msg assistant"); - wrap.appendChild(el("div", "role", "Assistente")); - const bubble = el("div", "bubble"); - const det = el("details", "thinking"); - det.appendChild(el("summary", null, "Pensiero")); - const reasoningNode = el("div", "reasoning", ""); - det.appendChild(reasoningNode); - det.hidden = true; - const contentNode = el("div", "content", ""); - bubble.appendChild(det); - bubble.appendChild(contentNode); - wrap.appendChild(bubble); - t.appendChild(wrap); - scrollDown(); - - let reasoning = "", text = "", usage = null; - await streamChat(state.current, content, attachments, (chunk) => { - const d = chunk.choices && chunk.choices[0] && chunk.choices[0].delta; - if (d && d.reasoning_content) { - reasoning += d.reasoning_content; - reasoningNode.textContent = reasoning; - det.hidden = false; - det.open = true; // show the thinking live, so the wait is visible progress - } - if (d && d.content) { - if (!text) det.open = false; // fold the thinking once the answer starts - text += d.content; - contentNode.textContent = text; - } - if (chunk.usage) usage = chunk.usage; - scrollDown(); - }); - if (usage) bubble.appendChild(el("div", "usage", usageText(usage))); -} - -// Agent mode: stream tool_call / tool_result / final events (observability, no gate). +// The only turn path: tools are always on (no user toggle). Stream tool_call / +// tool_result / final events (observability, no gate). async function agentTurn(content, t, attachments) { const r = await fetch(`/api/sessions/${state.current}/chat`, { method: "POST", @@ -858,16 +792,6 @@ function wire() { e.target.value = ""; if (files.length) uploadFiles(files); }); - $("#agent-toggle").addEventListener("click", () => { - state.agent = !state.agent; - const b = $("#agent-toggle"); - b.classList.toggle("active", state.agent); - b.setAttribute("aria-pressed", String(state.agent)); - }); - // Tools are on by default: the framework is meant to act, not just chat. - const ab = $("#agent-toggle"); - ab.classList.toggle("active", state.agent); - ab.setAttribute("aria-pressed", String(state.agent)); $("#show-stats").addEventListener("click", showStats); $("#close-stats").setAttribute("aria-label", t("stats.close")); $("#close-stats").addEventListener("click", closeStats); diff --git a/web/index.html b/web/index.html index 3602c97..e5475cf 100644 --- a/web/index.html +++ b/web/index.html @@ -43,7 +43,6 @@