Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

direct chat: Thinking budget in the Reasoning effort menu (reasoning_budget_tokens); Off reaches the server as none

Niko122120e0bf2e9d6f
diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjs
index a84b0f409..b5cca37f1 100644
--- a/apps/host/server/index.mjs
+++ b/apps/host/server/index.mjs
@@ -480,12 +480,12 @@ async function runAgentTurn({ res, controller, chatId, body, message, workspaceI
}
}
-async function runTurn({ message, history = [], onFrame, signal, client, workspaceId = null, sessionId = null, remoteModel = null, runtimeModelId = undefined, nativeModelId, images=[], useTools=false, thinking='high' }) {
+async function runTurn({ message, history = [], onFrame, signal, client, workspaceId = null, sessionId = null, remoteModel = null, runtimeModelId = undefined, nativeModelId, images=[], useTools=false, thinking='high', thinkingBudget=0 }) {
if (remoteModel) return runRemoteTurn({ selection: remoteModel, message, history, onFrame, signal, workspaceId });
if(native.hasLive()||nativeModelId){
let instance;try{instance=native.resolveInstance(nativeModelId??native.state().defaultId);}catch(e){onFrame({type:'error',message:e.message});return {error:e.message};}const started=Date.now(),cancel=new AbortController();
const entry=serving.open({client:client??'Strata chat',endpoint:'/chat/completions',model:instance.apiModelId,instanceId:instance.id,gpuIds:instance.gpus.map(String),cancel:()=>cancel.abort()});
- try{serving.mark(entry.id,{state:'generating'});const applied=selectSkills(skillState,message,workspaceId);const result=await proxyCompletion({baseUrl:`http://127.0.0.1:${instance.port}/v1`,modelId:instance.apiModelId,authorization:instance.key,message,history,images,extra:{strata_mcp:useTools===true,reasoning_effort:({off:'none',max:'high'}[String(thinking).toLowerCase()]??String(thinking).toLowerCase())},systemPrompt:[SYSTEM_PROMPT,skillInstructions(applied)].filter(Boolean).join('\n\n'),signal:signal?AbortSignal.any([signal,cancel.signal]):cancel.signal,onFrame:frame=>onFrame({...frame,requestId:entry.id,model:instance.label,contextMax:instance.metrics?.engine?.max_context??instance.context,skills:applied.map(s=>s.name)})});serving.mark(entry.id,{...result,usageSource:result.usageSource});serving.finish(entry.id,{tokensOut:result.tokensOut,durationMs:Date.now()-started});return result;}catch(e){serving.finish(entry.id,{durationMs:Date.now()-started,error:e.message});onFrame({type:'error',message:e.message,requestId:entry.id});return {error:e.message};}
+ try{serving.mark(entry.id,{state:'generating'});const applied=selectSkills(skillState,message,workspaceId);const result=await proxyCompletion({baseUrl:`http://127.0.0.1:${instance.port}/v1`,modelId:instance.apiModelId,authorization:instance.key,message,history,images,extra:{strata_mcp:useTools===true,...(thinkingBudget>0&&String(thinking).toLowerCase()!=='off'?{reasoning_budget_tokens:thinkingBudget}:{}),reasoning_effort:({off:'none',max:'high'}[String(thinking).toLowerCase()]??String(thinking).toLowerCase())},systemPrompt:[SYSTEM_PROMPT,skillInstructions(applied)].filter(Boolean).join('\n\n'),signal:signal?AbortSignal.any([signal,cancel.signal]):cancel.signal,onFrame:frame=>onFrame({...frame,requestId:entry.id,model:instance.label,contextMax:instance.metrics?.engine?.max_context??instance.context,skills:applied.map(s=>s.name)})});serving.mark(entry.id,{...result,usageSource:result.usageSource});serving.finish(entry.id,{tokensOut:result.tokensOut,durationMs:Date.now()-started});return result;}catch(e){serving.finish(entry.id,{durationMs:Date.now()-started,error:e.message});onFrame({type:'error',message:e.message,requestId:entry.id});return {error:e.message};}
}
runtimeState();
let instance;
@@ -1439,7 +1439,7 @@ async function api(req, res, path, method, url) {
sessionId: typeof body.sessionId === 'string' ? body.sessionId : null,
remoteModel: body.remoteModel ?? null,
nativeModelId:body.nativeModelId,
- images,useTools:body.useTools===true,thinking:body.thinking??'high',
+ images,useTools:body.useTools===true,thinking:body.thinking??'high',thinkingBudget:Number.isInteger(body.thinkingBudget)&&body.thinkingBudget>0?Math.min(body.thinkingBudget,262144):0,
});
res.end();
return undefined;
diff --git a/apps/host/src/components/ComposerControls.tsx b/apps/host/src/components/ComposerControls.tsx
index def130df6..6b1bcf045 100644
--- a/apps/host/src/components/ComposerControls.tsx
+++ b/apps/host/src/components/ComposerControls.tsx
@@ -20,6 +20,8 @@ const modes: {
{ value: 'bypass', label: 'Bypass permissions', hint: 'Skip permission prompts' },
];
const efforts = ['Off', 'Low', 'Medium', 'High', 'Max'];
+/** The most tokens a reply may spend thinking (the server's reasoning_budget_tokens); 0 = no limit. */
+const THINKING_BUDGETS: [number, string][] = [[0, 'No limit'], [2048, '2K'], [8192, '8K'], [32768, '32K']];
const textTypes = /\.(txt|md|markdown|csv|tsx?|jsx?|py|json|css|rs|go|sh|html?|ya?ml|toml|xml|log)$/i;
const photoTypes = /\.(png|jpe?g|webp|gif|svg)$/i;
export function ComposerControls({ session, onPreview, onAttach, onError, onSlash, streaming, draft, onDraft }: {
@@ -48,6 +50,7 @@ export function ComposerControls({ session, onPreview, onAttach, onError, onSlas
attachLatest.current = onAttach;
const mode = modes.find(m => m.value === session?.preferences?.mode) ?? modes[0];
const effort = efforts.includes(session?.preferences?.thinking ?? '') ? session!.preferences!.thinking! : 'High';
+ const budget = session?.preferences?.thinkingBudget ?? 0;
const shortcut = MOD === '⌘' ? '⌘⇧A' : 'Ctrl+Shift+A';
async function openFile(selected: File | undefined) {
if (!selected)
@@ -160,7 +163,7 @@ export function ComposerControls({ session, onPreview, onAttach, onError, onSlas
<button role="menuitem" className="menu__item" onClick={() => { setMenu(false); onSlash(); }}><span className="slash-command-icon" aria-hidden="true">/</span>{tr("Slash commands")}</button>
</FloatingMenu> : null)}
{tr(preferences ? <FloatingMenu anchor={preferences === 'mode' ? modeTrigger.current : thinkingTrigger.current} title={tr(preferences === 'mode' ? 'Mode' : 'Reasoning effort')} width={preferences === 'mode' ? 330 : 280} onClose={() => setPreferences(null)}>
- {tr(preferences === 'mode' ? <>{tr(modes.map((option, index) => <button key={option.value} role="menuitemradio" aria-checked={mode.value === option.value} className="menu__item composer-mode-option" onClick={() => { setChatPreferences(session?.id, { mode: option.value }); setPreferences(null); }}><span><strong>{tr(option.label)}</strong><small>{tr(option.hint)}</small></span>{tr(mode.value === option.value ? <Icon name="check" size={16}/> : null)}<kbd className="menu-shortcut">{tr(index + 1)}</kbd></button>))}</> : <><div className="reasoning-menu-model"><Icon name={apiModel ? 'link' : modelFamilyIcon(loaded?.family)} size={18}/><strong>{tr(apiModel?.name ?? loaded?.family ?? 'No model loaded')}</strong></div><p className="composer-menu-heading">{tr("Reasoning effort")}</p>{tr(efforts.map(option => <button key={option} role="menuitemradio" aria-checked={effort === option} className="menu__item" onClick={() => { setChatPreferences(session?.id, { thinking: option }); setPreferences(null); }}>{tr(option)}<span className="spacer"/>{tr(effort === option ? <Icon name="check" size={16}/> : null)}</button>))}</>)}
+ {tr(preferences === 'mode' ? <>{tr(modes.map((option, index) => <button key={option.value} role="menuitemradio" aria-checked={mode.value === option.value} className="menu__item composer-mode-option" onClick={() => { setChatPreferences(session?.id, { mode: option.value }); setPreferences(null); }}><span><strong>{tr(option.label)}</strong><small>{tr(option.hint)}</small></span>{tr(mode.value === option.value ? <Icon name="check" size={16}/> : null)}<kbd className="menu-shortcut">{tr(index + 1)}</kbd></button>))}</> : <><div className="reasoning-menu-model"><Icon name={apiModel ? 'link' : modelFamilyIcon(loaded?.family)} size={18}/><strong>{tr(apiModel?.name ?? loaded?.family ?? 'No model loaded')}</strong></div><p className="composer-menu-heading">{tr("Reasoning effort")}</p>{tr(efforts.map(option => <button key={option} role="menuitemradio" aria-checked={effort === option} className="menu__item" onClick={() => { setChatPreferences(session?.id, { thinking: option }); setPreferences(null); }}>{tr(option)}<span className="spacer"/>{tr(effort === option ? <Icon name="check" size={16}/> : null)}</button>))}<p className="composer-menu-heading">{tr("Thinking budget")}</p>{tr(THINKING_BUDGETS.map(([value, label]) => <button key={value} role="menuitemradio" aria-checked={budget === value} disabled={effort === 'Off'} className="menu__item" onClick={() => { setChatPreferences(session?.id, { thinkingBudget: value }); setPreferences(null); }}>{tr(label)}<span className="spacer"/>{tr(budget === value ? <Icon name="check" size={16}/> : null)}</button>))}</>)}
</FloatingMenu> : null)}
<Dialog open={urlOpen} title={tr("Open a website")} onClose={() => setUrlOpen(false)} actions={<><Btn onClick={() => setUrlOpen(false)}>{tr("Cancel")}</Btn><Btn variant="primary" disabled={!url.trim()} onClick={() => {
diff --git a/apps/host/src/lib/store.ts b/apps/host/src/lib/store.ts
index f2ae03074..49973b0c9 100644
--- a/apps/host/src/lib/store.ts
+++ b/apps/host/src/lib/store.ts
@@ -1325,6 +1325,7 @@ export async function sendMessage(text: string) {
images:await Promise.all(pictures.map(photoData)),
useTools:state.sessions.find(s=>s.id===sessionId)?.preferences?.useTools===true,
thinking:state.sessions.find(s=>s.id===sessionId)?.preferences?.thinking??'High',
+ thinkingBudget:state.sessions.find(s=>s.id===sessionId)?.preferences?.thinkingBudget??0,
// The Mode menu's choice for this chat, read when the turn starts; the host applies it to the agent.
mode:state.sessions.find(s=>s.id===sessionId)?.preferences?.mode??'manual',
// So a skill narrowed to another workspace does not fire here.
diff --git a/apps/host/src/lib/types.ts b/apps/host/src/lib/types.ts
index a67a81b2d..8f2bc70ea 100644
--- a/apps/host/src/lib/types.ts
+++ b/apps/host/src/lib/types.ts
@@ -388,7 +388,7 @@ export interface Session {
previewOpen?: string;
closedPreviews?: string[];
showcaseAgentStates?: boolean;
- preferences?: { access?: 'read' | 'write' | 'full'; thinking?: string; mode?: ChatMode; useTools?:boolean; /** This chat's API model; absent or null means the local model. */ remoteModel?: RemoteModelSelection | null };
+ preferences?: { access?: 'read' | 'write' | 'full'; thinking?: string; thinkingBudget?: number; mode?: ChatMode; useTools?:boolean; /** This chat's API model; absent or null means the local model. */ remoteModel?: RemoteModelSelection | null };
/** A branch does not have retained per-turn input usage. */
statsAvailable?: boolean;
id: string;
diff --git a/apps/host/src/locales/de.json b/apps/host/src/locales/de.json
index 54031b6af..aa7e91109 100644
--- a/apps/host/src/locales/de.json
+++ b/apps/host/src/locales/de.json
@@ -2610,5 +2610,7 @@
"s2609": "Strata kann diese Dateien noch nicht ausführen.",
"s2610": "Strata führt die Qwen3.8-Flash-Next-Modelle aus. Laden Sie eines unter „Modelle“ herunter oder wählen Sie einen Ordner mit dessen Dateien.",
"s2611": "Diese Dateien konnten nicht geprüft werden.",
- "s2612": "Prüfen Sie, ob der Ordner vollständige GGUF-Dateien enthält, und versuchen Sie es erneut."
+ "s2612": "Prüfen Sie, ob der Ordner vollständige GGUF-Dateien enthält, und versuchen Sie es erneut.",
+ "s2613": "Denkbudget",
+ "s2614": "Unbegrenzt"
}
diff --git a/apps/host/src/locales/en.json b/apps/host/src/locales/en.json
index b8143341b..5a850a02f 100644
--- a/apps/host/src/locales/en.json
+++ b/apps/host/src/locales/en.json
@@ -2610,5 +2610,7 @@
"s2609": "Strata can’t run these files yet.",
"s2610": "Strata runs the Qwen3.8-Flash-Next models. Download one from Models, or choose a folder with its files.",
"s2611": "These files could not be checked.",
- "s2612": "Check that the folder holds complete GGUF files, then try again."
+ "s2612": "Check that the folder holds complete GGUF files, then try again.",
+ "s2613": "Thinking budget",
+ "s2614": "No limit"
}
diff --git a/apps/host/src/locales/es.json b/apps/host/src/locales/es.json
index 6ce088d56..79ffb4cc4 100644
--- a/apps/host/src/locales/es.json
+++ b/apps/host/src/locales/es.json
@@ -2610,5 +2610,7 @@
"s2609": "Strata aún no puede ejecutar estos archivos.",
"s2610": "Strata ejecuta los modelos Qwen3.8-Flash-Next. Descarga uno en Modelos o elige una carpeta con sus archivos.",
"s2611": "No se pudieron comprobar estos archivos.",
- "s2612": "Comprueba que la carpeta tenga archivos GGUF completos e inténtalo de nuevo."
+ "s2612": "Comprueba que la carpeta tenga archivos GGUF completos e inténtalo de nuevo.",
+ "s2613": "Presupuesto de razonamiento",
+ "s2614": "Sin límite"
}
diff --git a/apps/host/src/locales/ja.json b/apps/host/src/locales/ja.json
index ab7e481a8..57dc07650 100644
--- a/apps/host/src/locales/ja.json
+++ b/apps/host/src/locales/ja.json
@@ -2610,5 +2610,7 @@
"s2609": "Strata はこれらのファイルをまだ実行できません。",
"s2610": "Strata は Qwen3.8-Flash-Next のモデルを実行します。「モデル」からダウンロードするか、そのファイルのフォルダーを選んでください。",
"s2611": "これらのファイルを確認できませんでした。",
- "s2612": "フォルダーに完全な GGUF ファイルがあることを確認して、もう一度お試しください。"
+ "s2612": "フォルダーに完全な GGUF ファイルがあることを確認して、もう一度お試しください。",
+ "s2613": "思考の上限",
+ "s2614": "上限なし"
}
diff --git a/apps/host/src/locales/ko.json b/apps/host/src/locales/ko.json
index 619b845ca..fd3502de3 100644
--- a/apps/host/src/locales/ko.json
+++ b/apps/host/src/locales/ko.json
@@ -2610,5 +2610,7 @@
"s2609": "Strata가 아직 이 파일을 실행할 수 없습니다.",
"s2610": "Strata는 Qwen3.8-Flash-Next 모델을 실행합니다. 모델 화면에서 내려받거나 해당 파일이 있는 폴더를 선택하세요.",
"s2611": "이 파일을 확인할 수 없습니다.",
- "s2612": "폴더에 완전한 GGUF 파일이 있는지 확인한 뒤 다시 시도하세요."
+ "s2612": "폴더에 완전한 GGUF 파일이 있는지 확인한 뒤 다시 시도하세요.",
+ "s2613": "생각 예산",
+ "s2614": "제한 없음"
}
diff --git a/apps/host/src/locales/pt.json b/apps/host/src/locales/pt.json
index 24a0d65c0..ed959b996 100644
--- a/apps/host/src/locales/pt.json
+++ b/apps/host/src/locales/pt.json
@@ -2610,5 +2610,7 @@
"s2609": "O Strata ainda não consegue executar esses arquivos.",
"s2610": "O Strata executa os modelos Qwen3.8-Flash-Next. Baixe um em Modelos ou escolha uma pasta com os arquivos dele.",
"s2611": "Não foi possível verificar esses arquivos.",
- "s2612": "Verifique se a pasta tem arquivos GGUF completos e tente novamente."
+ "s2612": "Verifique se a pasta tem arquivos GGUF completos e tente novamente.",
+ "s2613": "Orçamento de raciocínio",
+ "s2614": "Sem limite"
}
diff --git a/apps/host/src/locales/ru.json b/apps/host/src/locales/ru.json
index 48d528f65..2eaebcb96 100644
--- a/apps/host/src/locales/ru.json
+++ b/apps/host/src/locales/ru.json
@@ -2610,5 +2610,7 @@
"s2609": "Strata пока не может запустить эти файлы.",
"s2610": "Strata запускает модели Qwen3.8-Flash-Next. Скачайте одну в разделе «Модели» или выберите папку с её файлами.",
"s2611": "Не удалось проверить эти файлы.",
- "s2612": "Убедитесь, что в папке полные файлы GGUF, и повторите попытку."
+ "s2612": "Убедитесь, что в папке полные файлы GGUF, и повторите попытку.",
+ "s2613": "Лимит размышлений",
+ "s2614": "Без ограничений"
}
diff --git a/apps/host/src/locales/zh.json b/apps/host/src/locales/zh.json
index 2b799427d..47a1a1028 100644
--- a/apps/host/src/locales/zh.json
+++ b/apps/host/src/locales/zh.json
@@ -2610,5 +2610,7 @@
"s2609": "Strata 暂时无法运行这些文件。",
"s2610": "Strata 运行 Qwen3.8-Flash-Next 模型。请在“模型”中下载其中一个,或选择存放其文件的文件夹。",
"s2611": "无法检查这些文件。",
- "s2612": "请确认文件夹里是完整的 GGUF 文件,然后重试。"
+ "s2612": "请确认文件夹里是完整的 GGUF 文件,然后重试。",
+ "s2613": "思考预算",
+ "s2614": "不限制"
}
diff --git a/apps/host/tests/thinking-direct.test.mjs b/apps/host/tests/thinking-direct.test.mjs
new file mode 100644
index 000000000..f5cee285c
--- /dev/null
+++ b/apps/host/tests/thinking-direct.test.mjs
@@ -0,0 +1,21 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+
+/* The direct chat path (no agent): the composer's Reasoning effort menu reaches the server as reasoning_effort ("Off" -> "none", which the
+ server turns into enable_thinking=false), and the Thinking budget as reasoning_budget_tokens, never when thinking is off. */
+const host = readFileSync(new URL('../server/index.mjs', import.meta.url), 'utf8');
+const composer = readFileSync(new URL('../src/components/ComposerControls.tsx', import.meta.url), 'utf8');
+const store = readFileSync(new URL('../src/lib/store.ts', import.meta.url), 'utf8');
+
+test('Off is sent as none and Max as high; the budget only with thinking on', () => {
+ assert.match(host, /reasoning_effort:\(\{off:'none',max:'high'\}/);
+ assert.match(host, /thinkingBudget>0&&String\(thinking\)\.toLowerCase\(\)!=='off'\?\{reasoning_budget_tokens:thinkingBudget\}/);
+});
+
+test('the budget travels from the menu to the request', () => {
+ assert.match(composer, /THINKING_BUDGETS/);
+ assert.match(composer, /thinkingBudget: value/);
+ assert.match(store, /thinkingBudget:state\.sessions\.find/);
+ assert.match(host, /thinkingBudget:Number\.isInteger\(body\.thinkingBudget\)/);
+});