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
feat(chat): server-authoritative tool capability for cloud models
purple4009c2490bc3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ad953a36..e997d1ef 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -72,7 +72,9 @@ Community fix release: works through every open GitHub issue plus the actionable### 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.+- 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.+- **LU Cloud now knows up front which models can't do tools.** The `/models` list carries a per-model tool-calling flag, so Agent mode is disabled before you ever send a request on the cloud chat models that lack function calling (Hermes 3, Euryale, MythoMax, Llama 4 Maverick, and friends) — no failed turn required. Plain chatting with those models still works.+- **Every chat model in the dropdown now shows a tools icon at a glance:** a green wrench for models that support tool calling, an amber marker for models that don't (whether the server declared it, or a run proved it). When the server returns its clean "can't run tools / can't read images" reason, LU surfaces that exact line instead of a generic error.### Fixed — Local Create now frees the chat model from VRAM before renderingdiff --git a/src/api/__tests__/provider-openai.test.ts b/src/api/__tests__/provider-openai.test.tsindex d9cf925d..439b4708 100644--- a/src/api/__tests__/provider-openai.test.ts+++ b/src/api/__tests__/provider-openai.test.ts@@ -701,5 +701,69 @@ describe('OpenAIProvider', () => {}vi.restoreAllMocks()})++ // LU Cloud proxy (2.5.8 server): 400 with a structured top-level `code` and+ // an honest `error` line. The proxy answers 400 now (was 502). The message+ // ("... can't run tools ...") has no standalone "tool" word for the regex,+ // so the structured code is what must tag it.+ it('tags the structured model_no_tools 400 body as tools_unsupported', async () => {+ const provider = new OpenAIProvider(makeConfig({ name: 'LU Cloud' }))+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(+ new Response(JSON.stringify({+ error: "Hermes 3 70B can't run tools or Agent/Code mode. Switch to a tool-capable model like Qwen3 30B.",+ code: 'model_no_tools',+ model: 'hermes-3-70b',+ }), { status: 400 })+ )+ try {+ await provider.chatWithTools('hermes-3-70b', [{ role: 'user', content: 'hi' }], toolDef)+ expect.fail('Should have thrown')+ } catch (e: any) {+ expect(e.code).toBe('tools_unsupported')+ expect(e.message).toMatch(/can't run tools/)+ }+ vi.restoreAllMocks()+ })++ it('tags the structured model_no_vision 400 body as vision_unsupported', async () => {+ const provider = new OpenAIProvider(makeConfig({ name: 'LU Cloud' }))+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(+ new Response(JSON.stringify({+ error: "MythoMax L2 13B can't read images. Switch to a vision model.",+ code: 'model_no_vision',+ model: 'mythomax-l2-13b',+ }), { status: 400 })+ )+ try {+ await provider.chatWithTools('mythomax-l2-13b', [{ role: 'user', content: 'hi' }], toolDef)+ expect.fail('Should have thrown')+ } catch (e: any) {+ expect(e.code).toBe('vision_unsupported')+ expect(e.message).toMatch(/can't read images/)+ }+ vi.restoreAllMocks()+ })+ })++ // 2.5.8 — the /models list now declares per-model tool capability. Parsing it+ // is what lets Agent/Code gate the 6 tool-less cloud models up front.+ describe('listModels supports_tools', () => {+ it('parses supports_tools:false and defaults missing to true', async () => {+ const provider = new OpenAIProvider(makeConfig({ name: 'LU Cloud' }))+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(+ new Response(JSON.stringify({+ data: [+ { id: 'qwen3-30b', object: 'model', supports_tools: true },+ { id: 'hermes-3-70b', object: 'model', supports_tools: false },+ { id: 'legacy-no-field', object: 'model' },+ ],+ }), { status: 200 })+ )+ const models = await provider.listModels()+ expect(models.find(m => m.id === 'qwen3-30b')?.supportsTools).toBe(true)+ expect(models.find(m => m.id === 'hermes-3-70b')?.supportsTools).toBe(false)+ expect(models.find(m => m.id === 'legacy-no-field')?.supportsTools).toBe(true)+ vi.restoreAllMocks()+ })})})diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex eb646576..27781f34 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -73,6 +73,12 @@ interface OpenAIModelEntry {name?: stringcontext_length?: numberinput_modalities?: string[]+ // LU Cloud /models declares per-model tool-calling support. Some cloud chat+ // models (Hermes 3, Euryale, MythoMax, Llama-4-Maverick, …) can't do function+ // calling; the server marks them false so Agent/Code mode can gate them up+ // front instead of eating a mid-run 400. Absent on backends that don't send+ // it → the mapping falls back to `true` (optimistic, corrected at runtime).+ supports_tools?: booleanthink?: 'toggle' | 'always' | 'never'}@@ -481,7 +487,7 @@ export class OpenAIProvider implements ProviderClient {KNOWN_CONTEXT[m.id] ??(await this.probeContextFromServer(m.id)) ??guessContextFromName(m.id),- supportsTools: true,+ supportsTools: m.supports_tools ?? true,})))}@@ -498,7 +504,11 @@ export class OpenAIProvider implements ProviderClient {provider: 'openai' as const,providerName: this.config.name,contextLength: m.context_length ?? KNOWN_CONTEXT[m.id] ?? guessContextFromName(m.id),- supportsTools: true,+ // Server-authoritative tool capability. `false` for the cloud chat+ // models that can't do function calling → the whole chain (Agent+ // toggle, dropdown icon, Code mode) gates them without a failed run.+ // Fallback `true` keeps older deployments (no field) optimistic.+ supportsTools: m.supports_tools ?? true,supportsVision: m.input_modalities?.includes('image') || undefined,thinkMode: m.think,}@@ -657,10 +667,17 @@ export class OpenAIProvider implements ProviderClient {let message = `${this.config.name}: Request failed`let code: string = 'network'let hasServerMessage = false+ // LU Cloud proxy tags impossible requests with a structured top-level code+ // (sibling of `error`): "model_no_tools" (tools sent to a model without+ // function calling) / "model_no_vision" (image sent to a text-only model).+ // Mapped to our kinds after the status switch so the honest `error` line+ // surfaces and Agent/Code can remember the model.+ let serverCode: string | undefinedtry {- const data = await res.json() as { error?: unknown; message?: string }+ const data = await res.json() as { error?: unknown; message?: string; code?: string }const err = data.error+ if (typeof data.code === 'string' && data.code.trim()) serverCode = data.code// OpenAI & most servers: { error: { message, code } }. But LM Studio and// llama.cpp commonly send a BARE string ({ error: "..." }) or a top-level// { message: "..." }. The old object-only read missed both → the real@@ -703,11 +720,17 @@ export class OpenAIProvider implements ProviderClient {// 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)))) {+ if (toolsSent && (res.status === 405 || ((res.status === 400 || res.status === 404 || res.status === 422) && /\btools?\b|function[_ ]?call/i.test(message)))) {code = 'tools_unsupported'if (!hasServerMessage) message = `${this.config.name}: this model does not support tools (function calling).`}+ // Server-authoritative capability rejection (LU Cloud proxy, HTTP 400).+ // Wins over the heuristic above: it names the exact reason and ships an+ // honest, user-facing `error` line (already captured as `message`).+ if (serverCode === 'model_no_tools') code = 'tools_unsupported'+ else if (serverCode === 'model_no_vision') code = 'vision_unsupported'+// 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/components/chat/AgentModeToggle.tsx b/src/components/chat/AgentModeToggle.tsxindex 6eef7226..c1e1a107 100644--- a/src/components/chat/AgentModeToggle.tsx+++ b/src/components/chat/AgentModeToggle.tsx@@ -7,6 +7,7 @@ import { useChatStore } from '../../stores/chatStore'import { useModelStore } from '../../stores/modelStore'import { useSettingsStore } from '../../stores/settingsStore'import { isAgentCompatible } from '../../lib/model-compatibility'+import { getToolCapability } from '../../api/tool-capability'import { FEATURE_FLAGS } from '../../lib/constants'import { AgentTutorial } from './AgentTutorial'import { AgentWorkspaceDialog } from './AgentWorkspaceDialog'@@ -26,12 +27,25 @@ export function AgentModeToggle() {const conversations = useChatStore((s) => s.conversations)const createConversation = useChatStore((s) => s.createConversation)const activeModel = useModelStore((s) => s.activeModel)+ const activeModelMeta = useModelStore((s) => s.models.find((m) => m.name === s.activeModel))const { agentModeActive, toggleAgentMode, tutorialCompleted, newChatHintDismissed } = useAgentModeStore()if (!FEATURE_FLAGS.AGENT_MODE || !activeConversationId) return nullconst isActive = agentModeActive[activeConversationId] ?? false- const isCompatible = activeModel ? isAgentCompatible(activeModel) : false+ // Tool-capability precedence, same order the dropdown icon uses so the toggle+ // and the marker never disagree:+ // 1. a run PROVED it rejects tools (reactive cache, cloud 405 / ollama+ // "does not support tools") → disabled, even if the name looks capable+ // 2. server-declared capability (LU Cloud /models → supports_tools): false+ // keeps Agent disabled up front so the user never eats a mid-run 400 on+ // the cloud models without function calling (Hermes 3, Euryale, …)+ // 3. otherwise the family name heuristic, unchanged for every local model+ const serverTools = activeModelMeta && 'supportsTools' in activeModelMeta ? activeModelMeta.supportsTools : undefined+ const isCompatible =+ (activeModel && getToolCapability(activeModel) === 'unsupported') ? false+ : serverTools !== undefined ? serverTools+ : (activeModel ? isAgentCompatible(activeModel) : false)const conversation = conversations.find((c) => c.id === activeConversationId)const hasMessages = (conversation?.messages?.length ?? 0) > 0diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 760452f9..879abf2a 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -765,13 +765,15 @@ export function ModelSelector({ openUpward = false }: { openUpward?: boolean } =</span>)}{/* 2.5.8 — tool-calling capability at a glance. Ban =- a model we've SEEN reject tools (cloud 405 / ollama- "does not support tools"), so it can't run Agent/Code.- Wrench = tool-capable (optimistic for cloud/ollama the- same way we already send tools; the ban corrects it if- a run proves otherwise). Text models only. */}+ no function calling, so Agent/Code can't use it:+ either the server declared it (LU Cloud+ supports_tools === false — Hermes 3, Euryale,+ MythoMax, Llama-4-Maverick, …) or we've SEEN it+ reject tools at runtime (cloud 405 / ollama "does+ not support tools"). Wrench = tool-capable. Text+ models only. */}{model.type === 'text' && (- getToolCapability(model.name) === 'unsupported' ? (+ (getToolCapability(model.name) === 'unsupported' || model.supportsTools === false) ? (<spanclassName="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"