Agent: a model's "Tool timeout (seconds)" reaches its MCP servers in the desktop agent (#5788)

The servers set up in a model's settings (MCP Tools tab) are the ones the desktop
agent connects to, but the model's "Tool timeout (seconds)" (mcp_timeout_s) reached
only the engine's own MCP client; the Harness's dsh-mcp-client still cut every
call at 60 s (the reporter's case). The host now hands the setting to the agent
(mcpTimeoutS) and the profile gives each of the model's servers that time unless
the server names its own; without the setting the client keeps its default. No
new text: the setting already exists.
Test: tests/agent-mcp-model-timeout.test.mjs: 2 of 3 fail on da6391c77, 3/3 pass
here; with timeout-format-verification and agent-tools-settings 29/29.
This commit is contained in:
Niko1221 committed 2026-11-16 14:45:20 +01:00
1 parent da6391c771
commit adafc50b5a
4 files changed
+43 -2

No files matched your search

+6 -1
View File
@@ -304,7 +304,12 @@ export function buildProfile({ local = [], connections = [], gate = true, tools
const defaultRoute = routes.find(r => r.kind === 'local' && r.instanceId === defaultInstance?.id) ?? routes.find(r => r.kind === 'local') ?? null;
// One Harness, one set of tool servers: the default local model's.
const mcpSkipped = [];
const mcp = mcpRows({ ...(defaultInstance?.mcpServers ?? {}), ...(tools.servers ?? {}) }, mcpEnv, mcpSkipped);
// The model's own servers wait as long as its "Tool timeout (seconds)" says (mcp_timeout_s), unless a server names its own (#5788);
// without either the client keeps its default (60 s).
const modelTimeoutS = Number(defaultInstance?.mcpTimeoutS) > 0 ? Number(defaultInstance.mcpTimeoutS) : undefined;
const modelServers = Object.fromEntries(Object.entries(defaultInstance?.mcpServers ?? {}).map(([name, s]) => [name,
modelTimeoutS && s && typeof s === 'object' && s.timeoutSec == null && s.timeout_s == null && s.timeout == null && s.toolCallTimeoutMs == null ? { ...s, timeout_s: modelTimeoutS } : s]));
const mcp = mcpRows({ ...modelServers, ...(tools.servers ?? {}) }, mcpEnv, mcpSkipped);
Object.assign(env, mcpEnv);
// The person's own instruction and command tools come from the app's tool server; a command tool asks in Manual like any connected tool.
const own = (kind, on) => on && tools.toolFile ? [{ id: `mcp-strata-${kind}`, name: '@deepseek-ai/dsh-mcp-client', config: { serverName: `strata-${kind}`, transport: 'stdio', command: process.execPath, args: [CUSTOM_TOOLS_SCRIPT, kind, tools.toolFile] } }] : [];
+2
View File
@@ -219,6 +219,8 @@ const agent = createAgentBridge({
slots: i.metrics?.live?.slots?.length || i.parallel || 1,
// The tool servers set up for this model (Settings, Tools): the agent connects to the same ones.
mcpServers: i.mcpServers,
// its "Tool timeout (seconds)": the agent waits as long for those servers as the engine does (#5788)
mcpTimeoutS: i.mcpTimeoutS ?? null,
})),
connections: () => modelProviders.withSecrets().map(c => ({ ...c, models: c.models.map(m => ({ ...m, vision: readsPicturesByDefault(m, visionProbe.known(c, m.id)), reasoning: m.reasoning ?? visionProbe.knownThinks(c, m.id) ?? null })) })),
log: line => console.log(line),
+1 -1
View File
@@ -503,7 +503,7 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}
if(!args.multiple){if(busy(requests().filter(r=>instances.has(r.instanceId))))throw new Error('Finish or cancel native requests before switching models.');for(const id of [...instances.keys()])await unload(id);}else if(matching)await unload(matching.id);
if(job.state!=='running')return;
writeFileSync(configPath,JSON.stringify(cfg,null,2),{mode:0o600});
const instance={id,apiModelId,fingerprint,context:entry.context??0,aliases:cfg.aliases??[],vision:!!cfg.vision,resourceProfile:cfg.ui_resource_profile??null,model:args.model,label:friendlyModelName(snapshot.catalog,args.model)??entry.model_name??args.model,port:cfg.port,gpus:Array.isArray(cfg.gpu)?cfg.gpu:cfg.gpu===undefined?[]:[cfg.gpu],status:'loading',phase:'loading',parallel:cfg.parallel??1,mcpServers:cfg.mcp_servers??cfg.mcpServers??{},key,configPath,loadedAt:new Date().toISOString(),metrics:null,error:null,...(picturesNote?{picturesNote}:{})};
const instance={id,apiModelId,fingerprint,context:entry.context??0,aliases:cfg.aliases??[],vision:!!cfg.vision,resourceProfile:cfg.ui_resource_profile??null,model:args.model,label:friendlyModelName(snapshot.catalog,args.model)??entry.model_name??args.model,port:cfg.port,gpus:Array.isArray(cfg.gpu)?cfg.gpu:cfg.gpu===undefined?[]:[cfg.gpu],status:'loading',phase:'loading',parallel:cfg.parallel??1,mcpServers:cfg.mcp_servers??cfg.mcpServers??{},mcpTimeoutS:cfg.mcp_timeout_s??null,key,configPath,loadedAt:new Date().toISOString(),metrics:null,error:null,...(picturesNote?{picturesNote}:{})};
/* Another model on the same graphics card: the engine takes the card's free memory, so a second one usually finds none. Loading goes on (recommend, never force); if it fails, the reason is said. */
const sharedWith=instance.gpus.length?[...instances.values()].find(i=>i.id!==id&&i.status!=='error'&&i.model!==args.model&&i.gpus.some(g=>instance.gpus.includes(g))):null;
const sharedSentence=sharedWith?`GPU ${instance.gpus.find(g=>sharedWith.gpus.includes(g))+1} is already used by ${sharedWith.label}, so this model did not fit there. Load it on another GPU, or unload ${sharedWith.label} first.`:null;
@@ -0,0 +1,34 @@
// #5788: the MCP servers set up for a model (its settings, MCP Tools tab) are the ones the desktop agent connects to, but the model's
// "Tool timeout (seconds)" (mcp_timeout_s) reached only the engine's own MCP client: the Harness's client cut every call at its 60 s
// default. The model's servers now take that setting unless a server names its own time.
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { buildProfile } from '../server/agent/profile.mjs';
const rowsOf = profile => {
const out = [];
const walk = v => { if (Array.isArray(v)) v.forEach(walk); else if (v && typeof v === 'object') { if (v.name === '@deepseek-ai/dsh-mcp-client' && v.config) out.push(v); else Object.values(v).forEach(walk); } };
walk(JSON.parse(profile.patch.split('\n').slice(1).join('\n'))); // the patch is a comment line, then JSON (as entriesOf in agent-tools-settings)
return Object.fromEntries(out.map(r => [r.config.serverName, r.config]));
};
const local = extra => [{ id: 'a', modelId: 'm', baseUrl: 'http://x', context: 32768, mcpServers: { ue5: { url: 'http://127.0.0.1:8000/mcp' }, own: { command: 'node', args: ['s.js'], timeout_s: 30 } }, ...extra }];
test('the model\'s Tool timeout reaches its MCP servers in the agent; a server\'s own time wins', () => {
const rows = rowsOf(buildProfile({ local: local({ mcpTimeoutS: 900 }), connections: [] }));
assert.equal(rows.ue5.toolCallTimeoutMs, 900000);
assert.equal(rows.own.toolCallTimeoutMs, 30000);
});
test('without the setting the client keeps its own default', () => {
const rows = rowsOf(buildProfile({ local: local({}), connections: [] }));
assert.equal(rows.ue5.toolCallTimeoutMs, undefined);
assert.equal(rows.own.toolCallTimeoutMs, 30000);
});
test('the host hands the model\'s setting to the agent', () => {
const index = readFileSync(new URL('../server/index.mjs', import.meta.url), 'utf8');
assert.match(index, /mcpServers: i\.mcpServers,\n[^\n]*\n\s*mcpTimeoutS: i\.mcpTimeoutS \?\? null,/);
const control = readFileSync(new URL('../server/native-control.mjs', import.meta.url), 'utf8');
assert.match(control, /mcpServers:cfg\.mcp_servers\?\?cfg\.mcpServers\?\?\{\},mcpTimeoutS:cfg\.mcp_timeout_s\?\?null,/);
});