From daa45b1e37fbaeff7d75353e091d500d28f78624 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 16 Oct 2026 01:11:17 +0200 Subject: [PATCH] thinking: the Strata server reads chat_template_kwargs, not a top-level enable_thinking (Off had no effect); plain output for read-only PowerShell noise --- apps/host/server/agent/events.mjs | 6 ++++++ apps/host/server/agent/profile.mjs | 9 +++++---- apps/host/tests/agent-events.test.mjs | 2 +- apps/host/tests/agent-tools.test.mjs | 14 ++++++++------ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/apps/host/server/agent/events.mjs b/apps/host/server/agent/events.mjs index 7862d4b3..7e0c3048 100644 --- a/apps/host/server/agent/events.mjs +++ b/apps/host/server/agent/events.mjs @@ -97,6 +97,12 @@ export function withPlain(raw) { * sentence says only what is known. */ export function outcomeText(tool, text) { + if (tool === 'pwsh' || tool === 'bash') { + // In the read-only modes PowerShell runs in Constrained Language Mode and complains about the Harness's own output-encoding line: + // noise appended after a command that worked. It says nothing about the command, so it is not shown. + text = text.replace(/\r?\n?\[stderr\]\r?\n(?:Cannot create type\. Only core types are supported in this language mode\.[\s\S]*?CannotCreateTypeConstrainedLanguage\s*)+$/, ''); + if (!text.trim()) text = '(no output)'; + } if ((tool === 'pwsh' || tool === 'bash') && /^\(no output\)$/.test(text.trim())) return 'The command finished without any error. It printed nothing, so there is nothing more to show.'; return text; } diff --git a/apps/host/server/agent/profile.mjs b/apps/host/server/agent/profile.mjs index 1938106c..c71c4523 100644 --- a/apps/host/server/agent/profile.mjs +++ b/apps/host/server/agent/profile.mjs @@ -100,8 +100,8 @@ export function localOutputBudget(context) { } /** - * The thinking levels the chat's Reasoning menu offers, as wire values for a local Strata model. `off` sends enable_thinking false; - * the rest send enable_thinking true plus the effort (the server reads both; "Max" is the highest effort it has). + * The thinking levels the chat's Reasoning menu offers, as wire values for a local Strata model. `off` sends + * chat_template_kwargs.enable_thinking false; the rest send it true plus reasoning_effort (the server maps high and max to its top level). */ export const LOCAL_EFFORTS = Object.freeze({ off: null, low: 'low', medium: 'medium', high: 'high', max: 'high' }); /** The menu's words to the Harness's level names. */ @@ -140,8 +140,9 @@ export function buildProfile({ local = [], connections = [], gate = true }) { api: 'openai-completions', baseURL: inst.baseUrl, apiKeyEnv: keyEnv, - // `qwen` thinking format: enable_thinking true/false plus reasoning_effort, which the Strata server reads. - compat: { supportsStore: false, thinkingFormat: 'qwen', supportsReasoningEffort: true }, + // The Strata server reads the thinking level from `chat_template_kwargs` (enable_thinking, reasoning_effort) or from a top-level + // reasoning_effort; a top-level `enable_thinking` (pi-ai's `qwen` format) is ignored, so the model went on thinking with the menu on Off. + compat: { supportsStore: false, thinkingFormat: 'chat-template', chatTemplateKwargs: { enable_thinking: { $var: 'thinking.enabled' }, reasoning_effort: { $var: 'thinking.effort', omitWhenOff: true } } }, models: [{ id: inst.modelId, name: inst.label || inst.modelId, contextWindow: context, maxTokens: localOutputBudget(context), input: inst.vision ? ['text', 'image'] : ['text'], diff --git a/apps/host/tests/agent-events.test.mjs b/apps/host/tests/agent-events.test.mjs index 3eeb540c..02504656 100644 --- a/apps/host/tests/agent-events.test.mjs +++ b/apps/host/tests/agent-events.test.mjs @@ -20,7 +20,7 @@ test('the generated profile names credentials, never carries them, and declares assert.equal(providers['strata-local'].models[0].contextWindow, 32768); assert.equal(providers['strata-local'].models[0].maxTokens, 28672, 'a local model may use nearly the whole window (it was 8192, which cut big answers off)'); assert.equal(providers['strata-local'].models[0].reasoning, true); - assert.equal(providers['strata-local'].compat.thinkingFormat, 'qwen'); + assert.equal(providers['strata-local'].compat.thinkingFormat, 'chat-template'); assert.equal(providers['api-c0nn-1234-ab'].models[1].contextWindow, ASSUMED_API_CONTEXT, 'an unknown API window is a stated assumption, not a catalog default'); assert.equal(entries.find(e => e.id === 'agent-default-model').config.provider, 'strata-local', 'local stays the default'); assert.equal(entries.find(e => e.id === 'session-title-llm').disabled, true); diff --git a/apps/host/tests/agent-tools.test.mjs b/apps/host/tests/agent-tools.test.mjs index a7901c2f..ad91601b 100644 --- a/apps/host/tests/agent-tools.test.mjs +++ b/apps/host/tests/agent-tools.test.mjs @@ -233,16 +233,18 @@ test('the output budget is not the old 8192, and the Reasoning menu reaches the await bridge.runTurn({ chatId, message: 'SCRIPT:echo hi', workspacePath: ws, mode: 'bypass', thinking, onFrame: () => {} }); return worker.requests.find(r => r.toolNames.length).params; }; + const ctk = p => p.chat_template_kwargs ?? {}; const off = await ask('think-off', 'Off'); - assert.equal(off.enable_thinking, false); + assert.equal(ctk(off).enable_thinking, false); assert.equal(ctk(off).reasoning_effort, undefined); + assert.equal(off.enable_thinking, undefined, 'a top-level enable_thinking is the field the Strata server ignores'); assert.ok(off.max_completion_tokens > 40000, `budget ${off.max_completion_tokens} (the window minus the prompt, never the old 8192)`); const high = await ask('think-high', 'High'); - assert.equal(high.enable_thinking, true); assert.equal(high.reasoning_effort, 'high'); + assert.equal(ctk(high).enable_thinking, true); assert.equal(ctk(high).reasoning_effort, 'high'); const low = await ask('think-low', 'Low'); - assert.equal(low.enable_thinking, true); assert.equal(low.reasoning_effort, 'low'); + assert.equal(ctk(low).enable_thinking, true); assert.equal(ctk(low).reasoning_effort, 'low'); const max = await ask('think-max', 'Max'); - assert.equal(max.enable_thinking, true); assert.equal(max.reasoning_effort, 'high'); + assert.equal(ctk(max).enable_thinking, true); assert.equal(ctk(max).reasoning_effort, 'high'); // the same chat switching its level between turns - assert.equal((await ask('think-off', 'High')).enable_thinking, true); - assert.equal((await ask('think-off', 'Off')).enable_thinking, false); + assert.equal(ctk(await ask('think-off', 'High')).enable_thinking, true); + assert.equal(ctk(await ask('think-off', 'Off')).enable_thinking, false); });