Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion desktop/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions desktop/test/tool-disabled-line.test.mjs
Original file line number Diff line number Diff line change
@@ -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'\) \{/);
});
Loading