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.

docs: CLAUDE.md entries 78-81 — Agent Overhaul v24 + regression fixes + Gemma bypass

PurpleDoubleD37cb7224e009
diff --git a/CLAUDE.md b/CLAUDE.md
index b3bc54bd..beb0ff3e 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -138,10 +138,20 @@ src-tauri/src/commands/ — Rust commands: install, process, download, prox
77. **Codex connection-error hints (2.3.3)** — `useCodex.ts` catch block now adds kontext hints: `/Failed to fetch/i` → "Is `ollama serve` running?", `/does not support tools/i` → "Pick a tool-capable model (Qwen 3, Llama 3.1+, Gemma 4)", `/timed out/i` → "Try smaller model or more targeted prompt".
+78. **Agent Overhaul v24 — 13-phase architecture rewrite (branch feature/agent-overhaul-v24, stays under 2.3.3)** — Big modular rewrite of the agent runtime, all phases on top of the prior 2.3.3 work. (1) `AgentBlock.toolCall` (singular) → `toolCalls: AgentToolCall[]` schema with `migrateBlockInPlace()` rehydrate via Zustand `persist({merge})`. (2) `toolAuditStore` ring buffer of every call with `stableArgsHash` (djb2 of canonicalised JSON). (3) Tool descriptions ≥80 chars with PREFER/NEVER hints. (4) `args-validator.ts` rejects bad args with hint to LLM before dispatch. (5) `tool-executor.ts:executeParallel` — `Promise.allSettled` with `sideEffectKey` grouping (file-write same-path serial, shell/code share `'exec'`, image/workflow share `'comfyui'`). (6) `in-turn-cache.ts` dedupes `(name, argsHash)` within one user turn, served result carries `status: 'cached' + cacheHit:true`. (7) `error-hints.ts` per-tool rules append ≤160-char retry hints to error messages. (8) MCP wiring: `ToolRegistry.registerExternal(serverId, tools, executor)`, tools prefixed `mcp__<id>__<name>`. (9) Embedding-based tool routing in `selectRelevantToolsAsync` once tool count >15 (cosine-sim, keyword fallback). (10) `AgentBudget` with `agentMaxToolCalls` (default 50) + `agentMaxIterations` (default 25) caps, halts cleanly. (11) `partial-args-accumulator.ts` library only — streaming-deltas → full args (UI wiring deferred). (12) `permissionStore.perToolOverrides` + `modeScope` ('chat'|'edit'|'agent'), `getPermissionLevelWithOverrides`. (13) `delegate_task` tool spawns sub-agent with isolated budget, max nesting depth 2.
+
+79. **Regression fixes from Agent Overhaul E2E (commit 47f41ca)** — Five regressions surfaced after v2.4.0 build + install (version bumps later reverted). (a) **Streaming dead in Chat tab** — `proxy_localhost_stream` in Rust collected all bytes via `resp.bytes().await` before returning. Fix in `src/api/backend.ts:localFetchStream`: direct `fetch()` as primary path (Ollama has CORS open on localhost → real chunked streaming), Rust proxy fallback only. (b) **Universal thinking-tag stripper** — new `src/lib/thinking-stripper.ts` handles non-canonical formats the char-state-machine misses: Gemma `<|?channel|?>thought`, alt names (`<thought>`, `<reasoning>`, `<reflect>`, `<deepthink>`), orphan openers. Applied DURING streaming in useChat.ts RAF path (`stripNonCanonicalTags`) and at stream-end in useCodex/useAgentChat (`finalStripThinkingTags`). Canonical `<think>…</think>` flow unchanged. (c) **Approval modal invisible + parallel deadlock** — `ApprovalDialog.tsx` rewritten as fullscreen backdrop modal (prominent buttons, **Enter=Approve**, **Esc=Reject**, autoFocus on Approve). Race fix: `approvalQueueRef: ApprovalEntry[]` (FIFO) replaces single `approvalRef` — N parallel tools used to overwrite each other's resolver and deadlock all but the last. Auto-permission tools bypass via `entry.ac.status !== 'pending_approval'` check inside `awaitApproval`. (d) **Codex stops after 1 tool** — `CODEX_SYSTEM_PROMPT` in useCodex.ts ships explicit AUTONOMY CONTRACT: "NEVER say 'Now I will create X' as plain text and stop. Execute ALL N steps in one session." (e) **FileTree auto-refresh** — `codexStore` gets `fileTreeVersion` counter, bumped by addEvent on `file_change`/`terminal_output`. FileTree subscribes and reloads on change → new files appear live. (f) **v2.4.2 hotfix** for React Error #130: `ToolCallBlock.STATUS_ICONS` was missing `'cached'` (Phase 6 added the status, the icon map didn't get it) → `<undefined />` → crash on second-call-cached scenario. Added `cached: Database` from lucide-react.
+
+80. **Gemma 3/4 plain-text planner bypass (commit ca6632d)** — Separate from #79b. After tag-stripping fixed `<|channel|>thought` leaks, surfaced that Gemma 3/4 with Ollama `think: false` drops into PLAIN-TEXT structured planning (`Plan:` / `Constraint Checklist:` / `Confidence Score:` / `Self-Correction during drafting:`) — no tags any stripper could remove. Tried explicit anti-planning system prompts ("IMPORTANT: Answer directly. Do not output a Plan…"). Gemma ignores them. **Working fix**: new `isPlainTextPlanner(modelName)` helper in `src/lib/model-compatibility.ts` (gemma3/gemma4 base names). When User has Thinking OFF AND model is plain-text-planner, pass `thinking: undefined` (Ollama default = tagged thinking ON) instead of `false`. Gemma then emits `<|channel|>thought` markers that the thinking-stripper removes cleanly; `keepThinking === false` gate drops the native thinking field. Same UX (clean answer, no preamble), trade-off is hidden token spend on internal reasoning. Wired identically in useChat.ts / useAgentChat.ts / useCodex.ts. The dead anti-planning prompts removed.
+
+81. **Version policy: stay at 2.3.3** — Don't bump per regression fix during a session. Public number is the release-train label, not a dev-build counter. Overwrite `LU-<ver>-setup.exe` on Desktop in place rather than creating 2.3.4/2.4.x trail. See `feedback_versioning.md`.
+
### What's LEFT to finish v2.3.0:
-1. **Tauri proxy_localhost investigation** — reqwest in Tauri subprocess can't reach localhost. Direct fetch workaround in place but root cause unknown. Low priority since workaround works. Deferred to next release.
+1. **Tauri proxy_localhost investigation** — reqwest in Tauri subprocess can't reach localhost. Direct fetch workaround now also primary path for streaming via #79a. Root cause still unknown. Low priority.
2. **LTX VAEDecode reference** — dynamic-workflow.ts line 263: vaeSourceId incorrectly points to UNETLoader output for LTX strategy. Fix when LTX model is installed for testing.
-3. **Codex file tree auto-refresh** — File tree in Codex tab doesn't update when files are created during a session. Needs refresh button or fs watcher to auto-detect changes.
+3. **~~Codex file tree auto-refresh~~** — RESOLVED in #79e via `fileTreeVersion` counter on codexStore.
+4. **Codex incremental content streaming** — currently `chatWithTools` non-streaming by-design (agent needs full response before parsing tool calls). Tool-call blocks ARE shown live (FileTree updates, blocks render with running/completed status). Text between iterations only appears at end of each iteration. Refactor to incremental content streaming (using Phase 11 partial-args-accumulator) is possible if user asks.
+5. **Mobile/remote.rs thinking-stripper port** — Mobile still uses inline regex stripping in `pushChunkContent`. Could port `thinking-stripper.ts` patterns over but Remote works fine in current state. Low priority.
### Files modified in this branch (30+ files):
- `src/api/comfyui.ts` — 8 new ModelTypes (incl. zimage), COMPONENT_REGISTRY, uploadImage(), inputImage/denoise in GenerateParams, findMatchingVAE/CLIP for zimage