Skip to content

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.

fix: Gemma 3/4 plain-text planning bypass + revert version to 2.3.3

PurpleDoubleDca6632d8755f
diff --git a/package.json b/package.json
index 14796d3a..1e187611 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "locally-uncensored",
- "version": "2.4.2",
+ "version": "2.3.3",
"private": false,
"description": "Generate anything — text, images, video. Locally. Uncensored.",
"license": "AGPL-3.0",
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index cb70d0ea..f0a3376d 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -2508,7 +2508,7 @@ dependencies = [
[[package]]
name = "locally-uncensored"
-version = "2.4.2"
+version = "2.3.3"
dependencies = [
"axum",
"base64 0.22.1",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 764cc98a..4bece290 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "locally-uncensored"
-version = "2.4.2"
+version = "2.3.3"
description = "Private, local AI chat & image/video generation"
authors = ["purpledoubled"]
edition = "2021"
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index bc550d6a..348a4d1a 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
"productName": "Locally Uncensored",
- "version": "2.4.2",
+ "version": "2.3.3",
"identifier": "com.purpledoubled.locally-uncensored",
"build": {
"beforeBuildCommand": "npm run build",
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index 2ca11316..15c01ec4 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -11,7 +11,7 @@ import { retrieveContext } from '../api/rag'
import { speakStreaming, isSpeechSynthesisSupported, getVoicesAsync } from '../api/voice'
import { toolRegistry } from '../api/mcp'
import { usePermissionStore } from '../stores/permissionStore'
-import { isThinkingCompatible } from '../lib/model-compatibility'
+import { isThinkingCompatible, isPlainTextPlanner } from '../lib/model-compatibility'
// Legacy compat imports (still used by some callers)
import { getToolPermission, executeAgentTool, AGENT_TOOL_DEFS } from '../api/tool-registry'
import { getToolCallingStrategy, type ToolCallingStrategy } from '../lib/model-compatibility'
@@ -409,18 +409,25 @@ export function useAgentChat() {
let turnContent = ''
let turnThinking = ''
+ // Plain-text-planner escape: Gemma 3/4 with think=false drops
+ // into structured plain-text planning (Plan: / Constraint
+ // Checklist: / Confidence Score:) with no tags to strip. Pass
+ // `undefined` instead so Ollama keeps the model in tagged-
+ // thinking mode; the stripper removes the tags silently.
+ const canThinkAgent = isThinkingCompatible(activeModel)
+ const plainPlanAgent = isPlainTextPlanner(activeModel)
+ const thinkOpt: boolean | undefined = canThinkAgent
+ ? (settings.thinkingEnabled === false && plainPlanAgent
+ ? undefined
+ : settings.thinkingEnabled === true)
+ : undefined
+
const chatOptions = {
temperature: settings.temperature,
topP: settings.topP,
topK: settings.topK,
maxTokens: settings.maxTokens || undefined,
- // Tri-state: thinking-compatible models get an explicit true|false
- // (OFF → tell Ollama `think: false` so the model stops thinking
- // instead of secretly thinking + hiding it). Non-thinking models
- // get `undefined` so the field is omitted entirely.
- thinking: isThinkingCompatible(activeModel)
- ? settings.thinkingEnabled === true
- : (undefined as unknown as boolean),
+ thinking: thinkOpt as unknown as boolean,
signal: abort.signal,
}
diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.ts
index f09b3e6b..ac057f3a 100644
--- a/src/hooks/useChat.ts
+++ b/src/hooks/useChat.ts
@@ -13,7 +13,7 @@ import { useAgentChat } from "./useAgentChat"
import { useMemory } from "./useMemory"
import { useAgentModeStore } from "../stores/agentModeStore"
import { getProviderForModel, getProviderIdFromModel } from "../api/providers"
-import { isThinkingCompatible } from "../lib/model-compatibility"
+import { isThinkingCompatible, isPlainTextPlanner } from "../lib/model-compatibility"
import { stripNonCanonicalTags, finalStripThinkingTags } from "../lib/thinking-stripper"
import type { ChatStreamChunk } from "../api/providers/types"
import type { ImageAttachment } from "../types/chat"
@@ -168,9 +168,20 @@ export function useChat() {
// (true or false). For every other model we leave `thinking`
// undefined so the provider omits `think` entirely and Ollama does
// whatever it normally does.
+ //
+ // Exception: plain-text-planner models (Gemma 3/4). Their `think:
+ // false` path emits structured plain-text planning that has no
+ // tags. We pass `undefined` instead (= Ollama default) so the model
+ // stays in tagged-thinking mode; the thinking-stripper then removes
+ // the tags silently and keepThinking=false below drops the native
+ // thinking field, so the user sees a clean answer without a
+ // planning preamble.
const canThink = isThinkingCompatible(activeModel)
+ const plainTextPlanner = isPlainTextPlanner(activeModel)
const useThinking: boolean | undefined = canThink
- ? settings.thinkingEnabled === true
+ ? (settings.thinkingEnabled === false && plainTextPlanner
+ ? undefined
+ : settings.thinkingEnabled === true)
: undefined
const chatOpts = {
temperature: settings.temperature,
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index 0fadd151..f5b43e9f 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -13,7 +13,7 @@ import { chatNonStreaming } from '../api/agents'
import type { CodexEvent } from '../types/codex'
import type { AgentBlock, AgentToolCall } from '../types/agent-mode'
import { selectRelevantTools } from '../lib/tool-selection'
-import { isThinkingCompatible } from '../lib/model-compatibility'
+import { isThinkingCompatible, isPlainTextPlanner } from '../lib/model-compatibility'
import type { ChatMessage, ToolCall, ToolDefinition } from '../api/providers/types'
import { executeParallel, applyResultToToolCall, type ExecutionRequest } from '../api/agents/tool-executor'
import { useToolAuditStore } from '../stores/toolAuditStore'
@@ -191,13 +191,19 @@ export function useCodex() {
let toolCalls: ToolCall[] = []
let turnContent = ''
+ // Plain-text-planner escape for Gemma 3/4 — see useChat.ts.
+ const canThinkCx = isThinkingCompatible(activeModel)
+ const plainPlanCx = isPlainTextPlanner(activeModel)
+ const thinkOptCx: boolean | undefined = canThinkCx
+ ? (settings.thinkingEnabled === false && plainPlanCx
+ ? undefined
+ : settings.thinkingEnabled === true)
+ : undefined
+
const chatOptions = {
temperature: 0.1, // Low temp for coding precision
maxTokens: settings.maxTokens || undefined,
- // Tri-state think flag — see useChat.ts for rationale.
- thinking: isThinkingCompatible(activeModel)
- ? settings.thinkingEnabled === true
- : (undefined as unknown as boolean),
+ thinking: thinkOptCx as unknown as boolean,
signal: abort.signal,
}
diff --git a/src/lib/model-compatibility.ts b/src/lib/model-compatibility.ts
index 7cfe0886..48381e12 100644
--- a/src/lib/model-compatibility.ts
+++ b/src/lib/model-compatibility.ts
@@ -79,6 +79,28 @@ export function isThinkingCompatible(modelName: string | null): boolean {
return THINKING_COMPATIBLE.some(f => baseName.startsWith(f))
}
+/**
+ * Gemma 3/4 are thinking-compatible but their `think: false` path produces
+ * plain-text structured planning (`Plan:`, `Constraint Checklist:`,
+ * `Confidence Score:`) that has no tags we can strip — the model trained
+ * itself to talk its reasoning out loud when forced out of thinking mode.
+ *
+ * The `think: true` path produces `<|channel|>thought` tags instead, which
+ * our thinking-stripper can remove cleanly.
+ *
+ * So when the user toggles Thinking OFF on a Gemma model, we actually pass
+ * `thinking: undefined` (let Ollama default to on), and rely on the stripper
+ * + the `keepThinking === false` gate to silently discard the tagged
+ * reasoning content from the UI. The user gets the clean final answer; the
+ * model doesn't leak a planning preamble.
+ */
+export function isPlainTextPlanner(modelName: string | null): boolean {
+ if (!modelName) return false
+ const name = modelName.toLowerCase()
+ const baseName = name.replace(/^[^/]+\//, '').replace(/:.*$/, '').replace(/-abliterated/g, '').replace(/-uncensored/g, '')
+ return baseName.startsWith('gemma3') || baseName.startsWith('gemma4')
+}
+
/**
* Models recommended for Claude Code (Anthropic API compat via Ollama 0.14+).
* These models handle agentic tool-use loops well with the Claude Code CLI.