The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(thinking): die Tag-Anweisung tritt zurueck, wo der echte Schalter sitzt
purple3c310c18f995
diff --git a/src/api/providers/__tests__/openai-template-thinking.test.ts b/src/api/providers/__tests__/openai-template-thinking.test.tsindex ce6ce922..258caecd 100644--- a/src/api/providers/__tests__/openai-template-thinking.test.ts+++ b/src/api/providers/__tests__/openai-template-thinking.test.ts@@ -25,6 +25,9 @@* Run: npx vitest run src/api/providers/__tests__/openai-template-thinking.test.ts*/import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'+import { readFileSync } from 'node:fs'+import { fileURLToPath } from 'node:url'+import { dirname, join } from 'node:path'const streamBody = 'data: {"choices":[{"delta":{"content":"hi"}}]}\n\ndata: [DONE]\n\n'@@ -151,3 +154,34 @@ describe('a local server that refuses the field is not mistaken for one that canexpect('chat_template_kwargs' in sent[0].body).toBe(false)})})++/**+ * And the tag injection steps aside where the real switch exists.+ *+ * Before the template switch, plain chat and the coding loop appended "reason+ * inside <think></think> tags" to the system prompt for every OpenAI-compatible+ * endpoint that declared nothing. On a LOCAL backend that now arrives on top of+ * a template that has already opened the thought — the same double instruction+ * that trapped David's cloud Qwen3.6 in a reasoning loop on 2026-07-12, one+ * layer down. Cloud endpoints that declare nothing keep the injection: it is+ * still the only thing that can ask them.+ */+describe('the tag injection and the template switch do not stack', () => {+ const read = (rel: string) =>+ readFileSync(join(dirname(fileURLToPath(import.meta.url)), '../../..', rel), 'utf8')++ it('plain chat skips the injection for a local backend', () => {+ expect(read('hooks/useChat.ts')).toContain("&& !isLocalModelByName(activeModel)) {")+ })++ it('the coding loop does the same', () => {+ expect(read('hooks/useCodex.ts')).toContain("&& !isLocalModelByName(activeModel)) {")+ })++ it('NEGATIVE CONTROL: the injection itself is still there for everyone else', () => {+ for (const f of ['hooks/useChat.ts', 'hooks/useCodex.ts']) {+ expect(read(f)).toContain('reason through your thinking inside <think></think> tags')+ expect(read(f)).toContain("providerId !== 'ollama'")+ }+ })+})diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.tsindex f5cbdfe9..41b65c34 100644--- a/src/hooks/useChat.ts+++ b/src/hooks/useChat.ts@@ -28,6 +28,7 @@ import { modelOutOfMode } from "../lib/modeGate"import { syncOllamaHealthFromError } from "../lib/sync-ollama-health"import { isThinkingCompatible, isPlainTextPlanner } from "../lib/model-compatibility"import { stripNonCanonicalTags, finalStripThinkingTags, settleThinking } from "../lib/thinking-stripper"+import { isLocalModelByName } from "../api/agents/model-locality"import { isMultimodalUnsupportedError, MULTIMODAL_UNSUPPORTED_MESSAGE } from "../lib/ollama-errors"import type { ImageAttachment, Message } from "../types/chat"import { isGroupChat, groupSystemPrompt, groupHistory, stripImpersonatedSpeakers } from "../lib/group-chat"@@ -529,7 +530,14 @@ export function useChat() {const activeMeta = useModelStore.getState().models.find((m) => m.name === activeModel)const thinkMode = activeMeta && 'thinkMode' in activeMeta ? activeMeta.thinkMode : undefinedconst canThink = thinkMode ? thinkMode === 'toggle' : isThinkingCompatible(activeModel)- if (settings.thinkingEnabled && providerId !== 'ollama' && canThink && thinkMode === undefined) {+ // And not for a LOCAL OpenAI-compatible backend any more (2.6.7+ // Denk-Audit): the built-in engine, LM Studio, llama.cpp and friends+ // render the model's own template, which has a real thinking switch the+ // provider now flips through chat_template_kwargs. Asking for tags on top+ // of a template that already opened the thought is the same double+ // instruction that trapped the cloud reasoners in a loop, one layer down.+ if (settings.thinkingEnabled && providerId !== 'ollama' && canThink && thinkMode === undefined+ && !isLocalModelByName(activeModel)) {systemPrompt = (systemPrompt || '') + '\n\nBefore answering, reason through your thinking inside <think></think> tags. Your thinking will be hidden from the user. After thinking, provide your answer outside the tags.'}diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex 905014f4..905e8945 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -629,7 +629,13 @@ export function useCodex() {// For non-Ollama providers, inject thinking via system prompt — only for// models where the Think toggle actually applies (thinkMode gate).- if (settings.thinkingEnabled && providerId !== 'ollama' && codexCanThink(activeModel)) {+ // Not for a LOCAL OpenAI-compatible backend any more (2.6.7 Denk-Audit):+ // those render the model's own template, which has a real thinking switch+ // the provider now flips through chat_template_kwargs. Asking for tags on+ // top of a template that already opened the thought is a double+ // instruction, and that is what loops a reasoner.+ if (settings.thinkingEnabled && providerId !== 'ollama' && codexCanThink(activeModel)+ && !isLocalModelByName(activeModel)) {systemPrompt += '\n\nBefore answering, reason through your thinking inside <think></think> tags. Your thinking will be hidden from the user. After thinking, provide your answer outside the tags.'}