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(chat): clean error and picker marker for models without tool calling
purplee207a8befaac
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f7b373d5..ad953a36 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -70,6 +70,10 @@ Community fix release: works through every open GitHub issue plus the actionable- **Every video family core ComfyUI can animate is wired**, schema-driven from the live `/object_info`: WAN 2.1 i2v (`WanImageToVideo`), Hunyuan i2v (`HunyuanImageToVideo`), LTX (`LTXVImgToVideo`), Cosmos (`CosmosImageToVideoLatent`) on the main builder path — WAN 2.2 TI2V, SVD and FramePack already animated via their dedicated builders. Mochi (t2v-only) and a ComfyUI missing the family's node reject with an actionable message instead of silently ignoring the source image.- **The model picker only offers models that can actually do the op**: Animate lists i2v-capable models (explicit `i2v`/`ti2v` tags, SVD, FramePack, LTX, Cosmos Video2World), Video lists t2v-capable ones — SVD/FramePack drop out there, dual models (WAN 2.2 TI2V, LTX) stay in both. Same gating in the chat model-picker card.+### Fixed — A model without tool calling now fails with a clear message, not a raw error++- Picking a model that does not support function calling and then using Agent or Code mode (or Chat with tools on) made the hosted inference endpoint answer HTTP 405, which surfaced as an opaque error or an aborted turn with no explanation (a paying user hit exactly this). LU now recognises that case across every OpenAI-compatible backend (LU Cloud / DeepInfra, LM Studio, custom endpoints) and shows a plain "this model does not support tool calling" note that says what to do: turn tools off, or switch to a tool-capable model. The chat model dropdown also remembers a model that rejected tool calls and marks it with a small indicator, so you do not blindly re-pick it and hit the same wall.+### Fixed — Local Create now frees the chat model from VRAM before rendering- On a single local GPU, a chat model sitting in VRAM (Ollama / LM Studio / the bundled engine) left ComfyUI fighting for the card — heavy CPU offload at best, a CUDA out-of-memory on the 14B video lanes (Talking Character, Motion) at worst. A local Create run now releases the chat backends first (they reload lazily on your next message), the same offload the Cloud switch already did, so the render gets the whole GPU. ComfyUI keeps its own checkpoint cached across consecutive Create runs, so back-to-back generations don't pay a reload. (On a large card where both would have fit, this trades a quick chat-model reload for guaranteed headroom — the conservative default for the common 8-12 GB tiers.)diff --git a/src/api/__tests__/provider-openai.test.ts b/src/api/__tests__/provider-openai.test.tsindex 32691b5e..d9cf925d 100644--- a/src/api/__tests__/provider-openai.test.ts+++ b/src/api/__tests__/provider-openai.test.ts@@ -636,4 +636,70 @@ describe('OpenAIProvider', () => {vi.restoreAllMocks()})})++ // 2.5.8 — a model without function calling that gets a tool-augmented request+ // makes DeepInfra / LU Cloud answer 405 (some servers 400/422 with a+ // tool/function message). parseError must tag that 'tools_unsupported' so the+ // chat layer shows a clean note instead of a raw status error / AbortError.+ describe('tools_unsupported (model without function calling)', () => {+ const toolDef = [{+ type: 'function' as const,+ function: { name: 'web_search', description: 'x', parameters: { type: 'object', properties: {} } },+ }]++ it('tags a 405 on a tool request as tools_unsupported', async () => {+ const provider = new OpenAIProvider(makeConfig({ name: 'LU Cloud' }))+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(new Response('', { status: 405 }))+ try {+ await provider.chatWithTools('some-model', [{ role: 'user', content: 'hi' }], toolDef)+ expect.fail('Should have thrown')+ } catch (e: any) {+ expect(e).toBeInstanceOf(ProviderError)+ expect(e.code).toBe('tools_unsupported')+ expect(e.message).toMatch(/tool/i)+ }+ vi.restoreAllMocks()+ })++ it('keeps an honest server message but still tags tools_unsupported', async () => {+ const provider = new OpenAIProvider(makeConfig({ name: 'LU Cloud' }))+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(+ new Response(JSON.stringify({ error: { message: 'Function calling is not supported for this model' } }), { status: 400 })+ )+ try {+ await provider.chatWithTools('some-model', [{ role: 'user', content: 'hi' }], toolDef)+ expect.fail('Should have thrown')+ } catch (e: any) {+ expect(e.code).toBe('tools_unsupported')+ expect(e.message).toMatch(/Function calling is not supported/)+ }+ vi.restoreAllMocks()+ })++ it('does NOT tag a 405 when no tools were sent', async () => {+ const provider = new OpenAIProvider(makeConfig())+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(new Response('', { status: 405 }))+ try {+ await provider.listModels()+ expect.fail('Should have thrown')+ } catch (e: any) {+ expect(e.code).not.toBe('tools_unsupported')+ }+ vi.restoreAllMocks()+ })++ it('does NOT tag an unrelated 400 that happens to carry tools', async () => {+ const provider = new OpenAIProvider(makeConfig())+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(+ new Response(JSON.stringify({ error: { message: 'context length exceeded' } }), { status: 400 })+ )+ try {+ await provider.chatWithTools('some-model', [{ role: 'user', content: 'hi' }], toolDef)+ expect.fail('Should have thrown')+ } catch (e: any) {+ expect(e.code).not.toBe('tools_unsupported')+ }+ vi.restoreAllMocks()+ })+ })})diff --git a/src/api/__tests__/tool-capability.test.ts b/src/api/__tests__/tool-capability.test.tsnew file mode 100644index 00000000..4b123b0d--- /dev/null+++ b/src/api/__tests__/tool-capability.test.ts@@ -0,0 +1,83 @@+/**+ * tool-capability cache (2.5.8) — learns which models reject tool calling from+ * real request outcomes, so the picker can flag them and Agent/Code can warn.+ * Run: npx vitest run src/api/__tests__/tool-capability.test.ts+ */+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import {+ getToolCapability,+ markToolsSupported,+ markToolsUnsupported,+ clearToolCapability,+ resetToolCapabilityCache,+} from '../tool-capability'++// vitest runs under the node env where localStorage is absent; the module+// gracefully no-ops without it, but we install a stub to exercise the cache.+const installLocalStorageStub = () => {+ const store: Record<string, string> = {}+ ;(globalThis as any).localStorage = {+ getItem: (k: string) => (k in store ? store[k] : null),+ setItem: (k: string, v: string) => { store[k] = v },+ removeItem: (k: string) => { delete store[k] },+ clear: () => { for (const k of Object.keys(store)) delete store[k] },+ }+}++describe('tool-capability cache', () => {+ beforeEach(() => {+ installLocalStorageStub()+ resetToolCapabilityCache()+ })++ it('reports unknown for an unseen model', () => {+ expect(getToolCapability('mystery-model')).toBe('unknown')+ })++ it('reports unknown for an empty id', () => {+ expect(getToolCapability('')).toBe('unknown')+ })++ it('remembers a model that rejected tool calls', () => {+ markToolsUnsupported('no-tools-model')+ expect(getToolCapability('no-tools-model')).toBe('unsupported')+ })++ it('remembers a model that supports tool calls', () => {+ markToolsSupported('good-model')+ expect(getToolCapability('good-model')).toBe('supported')+ })++ it('normalizes the provider prefix so cloud id and picker id converge', () => {+ // hooks mark the raw id sent to the provider; the picker looks up model.name+ markToolsUnsupported('lu-cloud::meta-llama/Meta-Llama-3.1-8B')+ expect(getToolCapability('meta-llama/Meta-Llama-3.1-8B')).toBe('unsupported')+ expect(getToolCapability('lu-cloud::meta-llama/Meta-Llama-3.1-8B')).toBe('unsupported')+ })++ it('clears a single entry back to unknown', () => {+ markToolsUnsupported('m')+ clearToolCapability('m')+ expect(getToolCapability('m')).toBe('unknown')+ })++ describe('negative-result decay', () => {+ beforeEach(() => vi.useFakeTimers())+ afterEach(() => vi.useRealTimers())++ it('decays a negative result to unknown after the 24h TTL', () => {+ vi.setSystemTime(new Date('2026-01-01T00:00:00Z'))+ markToolsUnsupported('decays')+ expect(getToolCapability('decays')).toBe('unsupported')+ vi.setSystemTime(new Date('2026-01-02T01:00:00Z')) // +25h+ expect(getToolCapability('decays')).toBe('unknown')+ })++ it('keeps a positive result sticky past the TTL', () => {+ vi.setSystemTime(new Date('2026-01-01T00:00:00Z'))+ markToolsSupported('sticky')+ vi.setSystemTime(new Date('2026-02-01T00:00:00Z')) // +1 month+ expect(getToolCapability('sticky')).toBe('supported')+ })+ })+})diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex bb01664b..eb646576 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -428,7 +428,7 @@ export class OpenAIProvider implements ProviderClient {}if (!res.ok) {- throw await this.parseError(res)+ throw await this.parseError(res, tools.length > 0)}const data: OpenAIResponse = await res.json()@@ -653,7 +653,7 @@ export class OpenAIProvider implements ProviderClient {// ── Error parsing ────────────────────────────────────────────- private async parseError(res: Response): Promise<ProviderError> {+ private async parseError(res: Response, toolsSent = false): Promise<ProviderError> {let message = `${this.config.name}: Request failed`let code: string = 'network'let hasServerMessage = false@@ -697,6 +697,17 @@ export class OpenAIProvider implements ProviderClient {code = 'not_found'}+ // A tool-augmented request rejected for the tools themselves. DeepInfra /+ // LU Cloud answer 405 for a model without function calling; some servers+ // 400/404/422 with a tool/function message. Tag it 'tools_unsupported' so+ // the chat layer shows a clean "this model can't do tool calling" note (and+ // remembers the model) instead of a raw status error. Guarded on toolsSent+ // so a plain 405 on a tool-less request is never mislabelled.+ if (toolsSent && (res.status === 405 || ((res.status === 400 || res.status === 404 || res.status === 422) && /\btool\b|function[_ ]?call/i.test(message)))) {+ code = 'tools_unsupported'+ if (!hasServerMessage) message = `${this.config.name}: this model does not support tools (function calling).`+ }+// LM Studio: model load fails when there's no inference runtime for the// model's format installed. The raw API error reads "No LM Runtime found// for model format 'gguf'" which doesn't tell a noob what to do —diff --git a/src/api/tool-capability.ts b/src/api/tool-capability.tsnew file mode 100644index 00000000..d2803d36--- /dev/null+++ b/src/api/tool-capability.ts@@ -0,0 +1,103 @@+/**+ * 2.5.8 — per-model tool-calling (function-calling) capability cache.+ *+ * The LU Cloud inference catalog does not expose which hosted models support+ * function calling, and local backends vary by model, so LU optimistically+ * sends `tools` and lets the provider decide. When a tool-augmented request is+ * rejected for the tools themselves (DeepInfra / LU Cloud returns HTTP 405,+ * Ollama returns a "does not support tools" error), the UI catch site records+ * that model here as tools-unsupported so:+ * - the chat model dropdown can flag it with a small marker, and+ * - a later Agent / Code run can warn before wasting another request.+ *+ * Mirrors `agents/format-capability.ts`: localStorage-backed, negative results+ * expire after a day so a re-quantised model or an upgraded server deployment+ * recovers on its own without a manual cache clear. No active probe — tool+ * support is learned from real request outcomes, never a synthetic call.+ */++const STORAGE_KEY = 'lu-tool-capability-v1'+/** How long a cached negative result is trusted before we re-try the model. */+const NEGATIVE_TTL_MS = 24 * 60 * 60 * 1000++export type ToolCapability = 'supported' | 'unsupported' | 'unknown'++type CacheEntry = {+ capability: 'supported' | 'unsupported'+ checkedAt: number+}++type CacheShape = Record<string, CacheEntry>++/**+ * Strip LU's `provider::` routing prefix so a lookup converges whether the+ * caller passes the raw id sent to the provider (hooks) or the picker's+ * `model.name` (which may carry the prefix). Keeps cloud + local keys aligned.+ */+function keyOf(model: string): string {+ const i = model.lastIndexOf('::')+ return i >= 0 ? model.slice(i + 2) : model+}++function loadCache(): CacheShape {+ try {+ if (typeof localStorage === 'undefined') return {}+ const raw = localStorage.getItem(STORAGE_KEY)+ if (!raw) return {}+ const parsed = JSON.parse(raw)+ return parsed && typeof parsed === 'object' ? parsed : {}+ } catch {+ return {}+ }+}++function saveCache(cache: CacheShape): void {+ try {+ if (typeof localStorage === 'undefined') return+ localStorage.setItem(STORAGE_KEY, JSON.stringify(cache))+ } catch {+ // Quota errors etc. — swallowed; capability is re-learned next run.+ }+}++/**+ * Cached tool-calling capability for a model. 'unknown' means we have never+ * seen a tool request resolve either way, so callers should still try (and+ * not block). Negative results older than NEGATIVE_TTL_MS decay to 'unknown'.+ */+export function getToolCapability(model: string): ToolCapability {+ if (!model) return 'unknown'+ const entry = loadCache()[keyOf(model)]+ if (!entry) return 'unknown'+ if (entry.capability === 'supported') return 'supported'+ if (Date.now() - entry.checkedAt > NEGATIVE_TTL_MS) return 'unknown'+ return 'unsupported'+}++/** Mark a model as supporting tool calling (a tool call actually landed). Sticky. */+export function markToolsSupported(model: string): void {+ if (!model) return+ const cache = loadCache()+ cache[keyOf(model)] = { capability: 'supported', checkedAt: Date.now() }+ saveCache(cache)+}++/** Mark a model as NOT supporting tool calling. Expires after NEGATIVE_TTL_MS. */+export function markToolsUnsupported(model: string): void {+ if (!model) return+ const cache = loadCache()+ cache[keyOf(model)] = { capability: 'unsupported', checkedAt: Date.now() }+ saveCache(cache)+}++/** Drop the cache entry for a model (forces a fresh attempt next use). */+export function clearToolCapability(model: string): void {+ const cache = loadCache()+ delete cache[keyOf(model)]+ saveCache(cache)+}++/** Debug / test helper — wipe the entire cache. */+export function resetToolCapabilityCache(): void {+ saveCache({})+}diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 35dfd36a..d936369f 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -1,6 +1,6 @@import { useState, useRef, useEffect } from 'react'import { motion, AnimatePresence } from 'framer-motion'-import { ChevronDown, Loader2, Power, PlayCircle, X, Cloud } from 'lucide-react'+import { Ban, ChevronDown, Loader2, Power, PlayCircle, X, Cloud } from 'lucide-react'import { useModels } from '../../hooks/useModels'import { useModelStore } from '../../stores/modelStore'import { useProviderStore } from '../../stores/providerStore'@@ -8,6 +8,7 @@ import { useSettingsStore } from '../../stores/settingsStore'import { useUIStore } from '../../stores/uiStore'import { unloadAllModels, loadModel, unloadModel, listRunningModels } from '../../api/ollama'import { displayModelName } from '../../api/providers'+import { getToolCapability } from '../../api/tool-capability'import { backendCall } from '../../api/backend'import { listLoadedLmStudioModels, loadLmStudioModel, unloadLmStudioModel } from '../../api/lmstudio'import { isLmStudioProvider } from '../../lib/hf-to-provider'@@ -763,6 +764,18 @@ export function ModelSelector({ openUpward = false }: { openUpward?: boolean } ={providerBadge.label}</span>)}+ {/* 2.5.8 — a model we've seen reject tool calls (cloud+ 405 / ollama "does not support tools") is flagged so+ the user doesn't re-pick it for Agent/Code and hit the+ same wall. Reactive: appears after the first failure. */}+ {model.type === 'text' && getToolCapability(model.name) === 'unsupported' && (+ <span+ className="inline-flex items-center shrink-0 text-amber-500/80"+ title="This model does not support tool calling, so Agent and Code mode cannot use it"+ >+ <Ban size={9} />+ </span>+ )}{/* §18 — inline load state while we auto-load thisLM Studio model on the way to selecting it. */}{isSelectingThis && (diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.tsindex 75549e09..6ba8afd8 100644--- a/src/hooks/useAgentChat.ts+++ b/src/hooks/useAgentChat.ts@@ -30,6 +30,7 @@ import { useMemoryStore } from '../stores/memoryStore'import { useVoiceStore } from '../stores/voiceStore'import { autoSpeak } from '../lib/ttsBridge'import { getProviderForModel, getProviderIdFromModel } from '../api/providers'+import { markToolsUnsupported } from '../api/tool-capability'import { buildExtractionPrompt, parseExtractionResponse } from '../lib/memory-extraction'import { useAgentWorkflowStore } from '../stores/agentWorkflowStore'import { WorkflowEngine } from '../lib/workflow-engine'@@ -1382,10 +1383,11 @@ export function useAgentChat() {convId!, assistantMessage.id,MULTIMODAL_UNSUPPORTED_MESSAGE)- } else if (errorMsg.includes('does not support tools')) {+ } else if ((err as { code?: string })?.code === 'tools_unsupported' || errorMsg.includes('does not support tools')) {+ markToolsUnsupported(modelToUse)useChatStore.getState().updateMessageContent(convId!, assistantMessage.id,- `This model does not support tool calling.\n\nThe auto-fix could not be applied. Try pulling a standard model like:\n• qwen2.5:7b\n• llama3.1:8b\n• mistral:7b`+ `This model does not support tool calling, so it can't run in Agent or Code mode (and Chat has tools on).\n\nTurn tools off, or switch to a model that supports tool calling:\n• local (Ollama / LM Studio): qwen2.5:7b, llama3.1:8b, mistral:7b\n• LU Cloud: pick a model shown with the tools badge`)} else if (errorMsg.includes('does not support thinking')) {// Graceful message for thinking errors (shouldn't reach here after retry, but just in case)diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex ad8e83a7..51ec2e0c 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -5,6 +5,7 @@ import { useModelStore } from '../stores/modelStore'import { useSettingsStore } from '../stores/settingsStore'import { useChatStore } from '../stores/chatStore'import { getProviderForModel, getProviderIdFromModel } from '../api/providers'+import { markToolsUnsupported } from '../api/tool-capability'import { toolRegistry } from '../api/mcp'import { usePermissionStore } from '../stores/permissionStore'import { getToolCallingStrategy } from '../lib/model-compatibility'@@ -1440,8 +1441,9 @@ export function useCodex() {let hint = ''if (/Failed to fetch|NetworkError|net::ERR/i.test(msg)) {hint = '\n\nHint: the Ollama server is unreachable. Is `ollama serve` running on localhost:11434?'- } else if (/does not support tools|tool.*not.*support/i.test(msg)) {- hint = '\n\nHint: this model does not support native tool calling. Pick a tool-capable model (Qwen 3, Llama 3.1+, Gemma 4) or switch to a model without the coder-only restriction.'+ } else if (e?.code === 'tools_unsupported' || /does not support tools|tool.*not.*support/i.test(msg)) {+ markToolsUnsupported(modelToUse)+ hint = '\n\nHint: this model does not support tool calling, so Code mode cannot use it. Pick a model that supports tool calling (Qwen 3, Llama 3.1+, Gemma 4) or an LU Cloud model shown with the tools badge.'} else if (/timed out/i.test(msg)) {hint = '\n\nHint: a tool call exceeded its time budget. For long builds, raise the command timeout, split the work, or run it via shell_execute_background.'}