From ca19566bae9e5d8af10f2f25b9f9a273f761214f Mon Sep 17 00:00:00 2001 From: Nadia Rodionova <273119990+sosidudku1@users.noreply.github.com> Date: Thu, 12 Nov 2026 03:50:10 +0300 Subject: [PATCH] desktop: show a line when the agent leaves a tool out because the server refused its schema The agent sends a tool_disabled frame (ATO-1417) with the sentence for the chat. Draw it as one system line in the turn, before the reply. An agent that never sends the frame changes nothing. --- desktop/renderer/renderer.js | 20 +++++++++++++++- desktop/test/tool-disabled-line.test.mjs | 29 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 desktop/test/tool-disabled-line.test.mjs diff --git a/desktop/renderer/renderer.js b/desktop/renderer/renderer.js index de70280e7..61cc88ac8 100644 --- a/desktop/renderer/renderer.js +++ b/desktop/renderer/renderer.js @@ -2145,10 +2145,17 @@ function providerSwitchedLine(p) { if (typeof p.from !== 'string' || typeof p.to !== 'string' || !p.from || !p.to) return ''; return p.from + ' failed, switched to ' + p.to + (typeof p.to_model === 'string' && p.to_model ? ' (' + p.to_model + ')' : '') + '.'; } +/** ATO-1417: the transcript line for a `tool_disabled` frame (the server refused the tool's schema), '' when it names no tool. */ +function toolDisabledLine(p) { + if (!p || typeof p !== 'object') return ''; + if (typeof p.notice === 'string' && p.notice.trim()) return p.notice.trim(); + if (typeof p.tool !== 'string' || !p.tool.trim()) return ''; + return 'Tool ' + p.tool.trim() + ' is disabled for this turn: the model server did not accept its schema.'; +} /* Item 38: the frames that draw into a turn's rows (onChatEvent); the others are bookkeeping and go on as they always did. */ const LIVE_DRAWS = new Set(['reasoning_progress', 'tool_progress', 'tool_result', 'tool_update', 'delta', 'progress_note', 'reply_attachments', 'fusion_worker', - 'steer_applied', 'finish', 'provider_waiting', 'provider_recovered', 'provider_switched', + 'steer_applied', 'finish', 'provider_waiting', 'provider_recovered', 'provider_switched', 'tool_disabled', // ATO-259 / ATO-295: context maintenance inside the turn (context-compaction.js). 'compaction_started', 'compaction_progress', 'compaction_completed', 'compaction_failed', 'history_trimmed']); /* ATO-259: the compaction row of the turn on screen (`rowId`, spinning until @@ -10602,6 +10609,17 @@ function onChatEvent(ev) { render(); return; } + /* ATO-1417: the model server refused one tool's JSON schema (LM Studio and + llama.cpp do this for some MCP schemas), and the agent resent the request + without it, so the model cannot use that tool this turn. The agent words + it and sends it once per tool per turn; one line in the transcript, + before the reply. An agent without this frame never sends it. */ + if (ev.kind === 'tool_disabled') { + const line = toolDisabledLine(ev.payload || {}); + if (line && item) S.log.splice(S.log.indexOf(item), 0, {id:nid(), k:'system', note:true, text: esc(line)}); + render(); + return; + } /* Run mode — Fusion. One leg of a fan-out started, ran a tool, ended or was cut short (`event: fusion_worker`, agent ≥ desktop/fusion-stream). The live list under the composer says what is happening; the transcript diff --git a/desktop/test/tool-disabled-line.test.mjs b/desktop/test/tool-disabled-line.test.mjs new file mode 100644 index 000000000..d172f3dd1 --- /dev/null +++ b/desktop/test/tool-disabled-line.test.mjs @@ -0,0 +1,29 @@ +// ATO-1417: a tool the model server refused (its schema) is one line in the transcript, never silent. +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { createContext, runInContext } from 'node:vm'; + +const renderer = readFileSync(new URL('../renderer/renderer.js', import.meta.url), 'utf8'); +const start = renderer.indexOf('function toolDisabledLine(p)'); +const end = renderer.indexOf('\n}\n', start) + 3; +const ctx = createContext({}); +runInContext(renderer.slice(start, end) + ';this.line = toolDisabledLine;', ctx); + +test("the agent's own sentence is shown as it is", () => { + assert.equal(ctx.line({ notice: 'Tool notion.search is disabled for this turn: the model server did not accept its schema.', tool: 'notion.search' }), + 'Tool notion.search is disabled for this turn: the model server did not accept its schema.'); +}); + +test('without a notice the tool name still says what is off; nothing to say gives an empty line', () => { + assert.equal(ctx.line({ tool: 'notion.search', reason: 'schema_rejected' }), + 'Tool notion.search is disabled for this turn: the model server did not accept its schema.'); + assert.equal(ctx.line({}), ''); + assert.equal(ctx.line({ tool: ' ' }), ''); + assert.equal(ctx.line(null), ''); +}); + +test('the frame draws into the turn and is handled by the chat event router', () => { + assert.match(renderer, /'provider_switched', 'tool_disabled',/); + assert.match(renderer, /if \(ev\.kind === 'tool_disabled'\) \{/); +});