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(models): one tool-calling verdict, and surfaces that respect it
purplec4b2a76cc2ea
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsxindex 69f99e7f..9abdf3aa 100644--- a/src/components/chat/CodexView.tsx+++ b/src/components/chat/CodexView.tsx@@ -78,39 +78,6 @@ function stripChannelTags(text: string): string {// chatty small model can't stack the same line. (The old CollapsibleAnswer// one-line-preview component was removed.)-// One-time hint that "/" opens the coding commands (David 2026-06-12: "kleiner-// hinweis über dem prompt fenster … nur im coding bereich … mit x zum wegdrücken,-// soll nur einmal erscheinen"). Persisted in localStorage so it never returns-// after dismissal. Code-view only — it's rendered solely inside CodexView.-const SLASH_HINT_KEY = 'lu-coding-slash-hint-dismissed'-function CodingCommandsHint() {- const [dismissed, setDismissed] = useState(() => {- try { return localStorage.getItem(SLASH_HINT_KEY) === '1' } catch { return false }- })- if (dismissed) return null- // Outer matches the ChatInput container (max-w-[70%] mx-auto) so the inner- // w-[60%] is 60 % of the REAL prompt width, centered (David 2026-06-12: "60%- // so breit wie das prompt fenster, in der mitte"). Monochrome — no colour, no- // icon — and an English UI string (David 2026-06-12: "in deutsch? … farbe weg- // … emoji weg").- return (- <div className="w-full max-w-[70%] mx-auto px-3 pt-1 flex justify-center">- <div className="w-[60%] flex items-center gap-1.5 px-2 py-1 rounded-md border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.03]">- <span className="flex-1 text-center text-[0.55rem] text-gray-500 dark:text-gray-400 leading-tight">- New. Type <span className="font-mono px-1 rounded bg-gray-200/70 dark:bg-white/10">/</span> for coding commands: /review, /commit, /test, /fix …- </span>- <button- onClick={() => { try { localStorage.setItem(SLASH_HINT_KEY, '1') } catch { /* private mode — just hide it for this session */ } setDismissed(true) }}- title="Dismiss"- className="flex items-center justify-center w-4 h-4 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors shrink-0"- >- <X size={11} />- </button>- </div>- </div>- )-}-export function CodexView() {const { sendInstruction, stopCodex, isRunning } = useCodex()const activeConversationId = useChatStore((s) => s.activeConversationId)@@ -515,7 +482,6 @@ export function CodexView() {<RealtimeCounter isRunning={codexGenerating} />{/* One-time "/" hint, directly above the prompt (Code view only). */}- <CodingCommandsHint />{/* Input */}<ChatInput@@ -523,7 +489,7 @@ export function CodexView() {onStop={stopCodex}isGenerating={isRunning}slashCommands- composerModel={<ModelSelector openUpward />}+ composerModel={<ModelSelector openUpward surface="code" />}composerActions={<PluginsDropdown openUpward />}/></div>diff --git a/src/components/chat/PermissionOverrideBar.tsx b/src/components/chat/PermissionOverrideBar.tsxindex 008e1b83..8f34b8a7 100644--- a/src/components/chat/PermissionOverrideBar.tsx+++ b/src/components/chat/PermissionOverrideBar.tsx@@ -1,7 +1,7 @@import { usePermissionStore } from '../../stores/permissionStore'import { useChatStore } from '../../stores/chatStore'import type { ToolCategory } from '../../api/mcp/types'-import { useImageToolNoti } from '../../hooks/useImageToolNoti'+import { useToolSupport } from '../../hooks/useToolSupport'import { FolderOpen, Terminal, Monitor, Globe, Cpu, Image, Film, GitBranch, Lock } from 'lucide-react'// Image AND video generation are LIVE (chat agent → ComfyUI; video unlocked@@ -23,33 +23,39 @@ const CATEGORIES: { key: ToolCategory; icon: typeof Globe; label: string }[] = [export function PermissionOverrideBar() {const activeConversationId = useChatStore((s) => s.activeConversationId)const { getEffectivePermissions, setConversationOverride } = usePermissionStore()- const { visible: imageNoti, dismiss: dismissImageNoti } = useImageToolNoti()+ // 2.5.9: a model that cannot call tools makes every row here a lie — flipping+ // one on changed nothing except how long the failure took to arrive.+ const { canUseTools, reason } = useToolSupport()if (!activeConversationId) return nullconst permissions = getEffectivePermissions(activeConversationId)const toggleTool = (cat: ToolCategory) => {- if (LOCKED.has(cat)) return- // First click on the image-tool noti only acknowledges it (purely visual,- // no activation — David 2026-06-06). After that the row toggles as normal.- if (cat === 'image' && imageNoti) { dismissImageNoti(); return }+ if (LOCKED.has(cat) || !canUseTools) returnconst current = permissions[cat]setConversationOverride(activeConversationId, cat, current === 'blocked' ? 'auto' : 'blocked')}return (<div>+ {!canUseTools && (+ <div className="px-1.5 py-1 text-[0.5rem] leading-snug text-amber-600 dark:text-amber-400/90">+ {reason}+ </div>+ )}{CATEGORIES.map(({ key, icon: Icon, label }) => {const isLocked = LOCKED.has(key)- const isOn = !isLocked && permissions[key] !== 'blocked'+ const isDisabled = isLocked || !canUseTools+ const isOn = !isDisabled && permissions[key] !== 'blocked'return (<buttonkey={key}onClick={() => toggleTool(key)}- disabled={isLocked}+ disabled={isDisabled}+ title={!canUseTools ? reason : undefined}className={`flex items-center gap-1.5 w-full px-1.5 py-[3px] text-[0.5rem] transition-colors ${- isLocked+ isDisabled? 'text-gray-400 dark:text-gray-700 cursor-default': isOn? 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5'@@ -62,13 +68,6 @@ export function PermissionOverrideBar() {<Icon size={8} className={isOn ? 'text-green-400' : 'text-gray-600'} />)}<span className={`flex-1 text-left ${isLocked ? 'line-through' : ''}`}>{label}</span>- {/* Image-tool discovery noti — small purple "1", purely visual,- clears on first click (David 2026-06-06). HW-gated by the hook. */}- {key === 'image' && imageNoti && (- <span className="min-w-[12px] h-[12px] flex items-center justify-center rounded-full bg-purple-500 text-[0.45rem] font-bold text-white leading-none px-0.5 mr-0.5">- 1- </span>- )}{isLocked ? (<span className="text-[0.4rem] text-gray-700">soon</span>) : (diff --git a/src/components/chat/PluginsDropdown.tsx b/src/components/chat/PluginsDropdown.tsxindex 2046547d..8b5fd1e3 100644--- a/src/components/chat/PluginsDropdown.tsx+++ b/src/components/chat/PluginsDropdown.tsx@@ -2,6 +2,7 @@ import { useState } from 'react'import { Plug, ChevronDown, Bone, User, Wrench } from 'lucide-react'import { useSettingsStore } from '../../stores/settingsStore'import { useChatStore } from '../../stores/chatStore'+import { useToolSupport } from '../../hooks/useToolSupport'import type { CavemanMode } from '../../types/settings'const CAVEMAN_MODES: { value: CavemanMode; label: string; desc: string }[] = [@@ -24,8 +25,12 @@ export function PluginsDropdown({ openUpward = false }: { openUpward?: boolean }// Chat-Tools (v2.5.3) — curated web/file/image/video tools in plain chat.// Default ON (undefined → on) so the feature works out of the box; the// toggle lets a user fall back to pure-text chat.- const chatToolsEnabled = useSettingsStore((s) => s.settings.chatToolsEnabled !== false)+ const chatToolsEnabledSetting = useSettingsStore((s) => s.settings.chatToolsEnabled !== false)const updateSettings = useSettingsStore((s) => s.updateSettings)+ // A model with no tool channel cannot run Chat Tools no matter what the+ // switch says, so show it off and disabled rather than on and broken.+ const { canUseTools, reason } = useToolSupport()+ const chatToolsEnabled = chatToolsEnabledSetting && canUseTools// Per-chat persona enable/disable (mirrors mobile). Defaults to true// for legacy chats where the flag is absent. The toggle in the@@ -79,18 +84,26 @@ export function PluginsDropdown({ openUpward = false }: { openUpward?: boolean }<span className="text-[0.5rem] text-gray-400 truncate">web · file · image · video</span></div><button- onClick={(e) => { e.stopPropagation(); updateSettings({ chatToolsEnabled: !chatToolsEnabled }) }}- title={chatToolsEnabled ? 'Disable tools in plain chat' : 'Enable web/file/image/video tools in plain chat'}+ onClick={(e) => { e.stopPropagation(); if (canUseTools) updateSettings({ chatToolsEnabled: !chatToolsEnabledSetting }) }}+ disabled={!canUseTools}+ title={!canUseTools ? reason : chatToolsEnabled ? 'Disable tools in plain chat' : 'Enable web/file/image/video tools in plain chat'}className={'shrink-0 flex items-center w-7 h-3.5 rounded-full transition-colors ' +- (chatToolsEnabled- ? 'bg-blue-500/40 hover:bg-blue-500/55 justify-end'- : 'bg-gray-300/30 dark:bg-white/10 hover:bg-gray-300/45 dark:hover:bg-white/15 justify-start')+ (!canUseTools+ ? 'bg-gray-300/20 dark:bg-white/5 cursor-default justify-start'+ : chatToolsEnabled+ ? 'bg-blue-500/40 hover:bg-blue-500/55 justify-end'+ : 'bg-gray-300/30 dark:bg-white/10 hover:bg-gray-300/45 dark:hover:bg-white/15 justify-start')}>- <span className="w-3 h-3 rounded-full bg-white shadow-sm mx-px" />+ <span className={`w-3 h-3 rounded-full shadow-sm mx-px ${canUseTools ? 'bg-white' : 'bg-white/40'}`} /></button></div>+ {!canUseTools && (+ <div className="pb-1.5 text-[0.5rem] leading-snug text-amber-600 dark:text-amber-400/90">+ {reason}+ </div>+ )}</div><div className="border-t border-gray-200 dark:border-white/[0.06] my-1" />diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 2942dc23..29aa6238 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -9,6 +9,7 @@ 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 { canUseTools } from '../../lib/tool-support'import { backendCall } from '../../api/backend'import { listLoadedLmStudioModels, loadLmStudioModel, unloadLmStudioModel } from '../../api/lmstudio'import { isLmStudioProvider } from '../../lib/hf-to-provider'@@ -408,10 +409,24 @@ function LoadToggle({ loaded, busy, disabled, onClick }: {// ── Component ─────────────────────────────────────────────────+export interface ModelSelectorProps {+ openUpward?: boolean+ /**+ * Which surface is asking. 'code' is the coding agent, which cannot do+ * anything at all without tool calls, so hosted models that have told us+ * they do not support tools are left out of the list entirely rather than+ * offered with a warning icon (David 2026-07-25: "Modelle ohne Tool-Support+ * z.B. nicht im Code-Bereich anzeigen"). Local models stay listed on every+ * surface — there the fallback XML path often still works, and when it does+ * not the run says so.+ */+ surface?: 'chat' | 'code'+}+// `openUpward` flips the dropdown to open above the trigger, right-aligned —// used when the picker lives in the composer action bar (bottom of the screen)// instead of the header. Header usage keeps the default downward/centered menu.-export function ModelSelector({ openUpward = false }: { openUpward?: boolean } = {}) {+export function ModelSelector({ openUpward = false, surface = 'chat' }: ModelSelectorProps = {}) {const { models, activeModel, setActiveModel, fetchModels } = useModels()const isModelLoading = useModelStore((s) => s.isModelLoading)const [open, setOpen] = useState(false)@@ -618,7 +633,15 @@ export function ModelSelector({ openUpward = false }: { openUpward?: boolean } =// FAMILY (Qwen/Gemma/Llama/…), not by provider, because users pick// models by lineage first and the backend that serves them is a// per-row badge.- const textModels = models.filter(m => m.type === 'text')+ const allTextModels = models.filter(m => m.type === 'text')+ // Code needs tools to do literally anything. A hosted model that has told us+ // it cannot call them is not a degraded choice there, it is a dead one, so it+ // does not get listed. Keep the ACTIVE model visible even if it fails the+ // check, or switching away from it becomes impossible.+ const textModels = surface === 'code'+ ? allTextModels.filter((m) => m.name === activeModel || canUseTools({ name: m.name, supportsTools: m.supportsTools }))+ : allTextModels+ const hiddenForCode = allTextModels.length - textModels.lengthconst groups = groupByFamily(textModels)const hasOllamaModels = textModels.some(m => ('provider' in m && m.provider === 'ollama') || !('provider' in m))@@ -674,6 +697,14 @@ export function ModelSelector({ openUpward = false }: { openUpward?: boolean } ="can't choose any models i have installed" symptom. */}<LmStudioServerHint onStarted={fetchModels} />+ {/* Say WHY the list is shorter here than in Chat, otherwise a+ missing favourite reads as a bug. */}+ {hiddenForCode > 0 && (+ <div className="px-2.5 py-1.5 border-b border-black/5 dark:border-white/[0.06] text-[0.55rem] text-gray-500">+ {hiddenForCode} cloud {hiddenForCode === 1 ? 'model is' : 'models are'} hidden here because they cannot call tools. They are still in Chat.+ </div>+ )}+{/* §18 — surfaced when an LM Studio auto-load (on select) failed,so the user isn't left wondering why the model didn't switch. */}{selectError && (diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex ba60e6e9..8a58c4b6 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -8,7 +8,7 @@ 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'+import { toolStrategyFor } from '../lib/tool-support'import { CODEX_CONFIRM_TOOLS, codexConfirmEnabled } from './codexShellGate'import { buildHermesToolPrompt, buildHermesToolResult, parseHermesToolCalls, stripToolCallTags, hasToolCallTags } from '../api/hermes-tool-calling'import { chatNonStreaming } from '../api/agents'@@ -336,9 +336,16 @@ export function useCodex() {// Resolve providerconst { provider, modelId } = getProviderForModel(activeModel)const providerId = getProviderIdFromModel(activeModel)- const strategy = providerId === 'ollama'- ? getToolCallingStrategy(activeModel)- : 'native'+ // Every non-Ollama provider used to be hardcoded to 'native' here, which+ // ignored both the server's `supports_tools` answer and the cache of models+ // a previous run watched reject a `tools` payload. The request went out+ // anyway, came back 405, and the negative expired 24 h later so the user+ // paid for the same discovery again. toolStrategyFor applies the same+ // precedence the dropdown and the Agent toggle use.+ const strategy = toolStrategyFor({+ name: activeModel,+ supportsTools: useModelStore.getState().models.find((m) => m.name === activeModel)?.supportsTools,+ })const modelToUse = activeModel.includes('::') ? activeModel.split('::')[1] : activeModel// Pin the text model driving this Codex run — parity with useAgentChat.diff --git a/src/hooks/useToolSupport.ts b/src/hooks/useToolSupport.tsnew file mode 100644index 00000000..1903c294--- /dev/null+++ b/src/hooks/useToolSupport.ts@@ -0,0 +1,40 @@+/**+ * The active model's tool-calling verdict, for the UI.+ *+ * Every surface that offers a tool control (the Chat Tools switch, the+ * per-category permission rows, the Agent toggle) needs the same answer, and+ * before 2.5.9 each computed its own version — so the Agent toggle could be+ * greyed out while the tool rows next to it stayed lit and silently produced+ * failing runs.+ */++import { useModelStore } from '../stores/modelStore'+import { resolveToolSupport, type ToolSupport } from '../lib/tool-support'++export interface ActiveToolSupport {+ support: ToolSupport+ /** False when tools cannot work with the current model at all. */+ canUseTools: boolean+ /** One short line to show next to a disabled control. Empty when enabled. */+ reason: string+ modelName: string | null+}++export function useToolSupport(): ActiveToolSupport {+ const activeModel = useModelStore((s) => s.activeModel)+ const supportsTools = useModelStore(+ (s) => s.models.find((m) => m.name === s.activeModel)?.supportsTools,+ )++ if (!activeModel) {+ return { support: 'none', canUseTools: false, reason: 'Pick a model first.', modelName: null }+ }++ const support = resolveToolSupport({ name: activeModel, supportsTools })+ return {+ support,+ canUseTools: support !== 'none',+ reason: support === 'none' ? 'This model cannot call tools. Pick another one to use these.' : '',+ modelName: activeModel,+ }+}diff --git a/src/lib/__tests__/tool-support.test.ts b/src/lib/__tests__/tool-support.test.tsnew file mode 100644index 00000000..b2e00c89--- /dev/null+++ b/src/lib/__tests__/tool-support.test.ts@@ -0,0 +1,87 @@+import { describe, it, expect, beforeEach, vi } from 'vitest'++// vitest runs on `node`, which has no localStorage — and tool-capability+// silently no-ops without it, so the cache half of the precedence would never+// be exercised. Stub it before importing anything that reads it.+const store = new Map<string, string>()+vi.stubGlobal('localStorage', {+ getItem: (k: string) => store.get(k) ?? null,+ setItem: (k: string, v: string) => { store.set(k, v) },+ removeItem: (k: string) => { store.delete(k) },+ clear: () => { store.clear() },+})++// Drive the reactive cache through its real API so the precedence under test+// is the one the app runs.+import { markToolsUnsupported, resetToolCapabilityCache } from '../../api/tool-capability'+import { resolveToolSupport, canUseTools, toolStrategyFor } from '../tool-support'++beforeEach(() => {+ store.clear()+ resetToolCapabilityCache()+})++describe('resolveToolSupport — one precedence for every surface', () => {+ it('a plain hosted model does native tool calling', () => {+ expect(resolveToolSupport({ name: 'lu-cloud::qwen3-32b' })).toBe('native')+ })++ it('a hosted model the server declares tool-less is out entirely', () => {+ // LU Cloud sets supports_tools:false on its story/roleplay models. Offering+ // them in Code meant a paid round-trip that always ended in a 405.+ expect(resolveToolSupport({ name: 'lu-cloud::mythomax-13b', supportsTools: false })).toBe('none')+ expect(canUseTools({ name: 'lu-cloud::mythomax-13b', supportsTools: false })).toBe(false)+ })++ it('a hosted model PROVEN to reject tools is out even without the flag', () => {+ markToolsUnsupported('lu-cloud::euryale-70b')+ expect(resolveToolSupport({ name: 'lu-cloud::euryale-70b' })).toBe('none')+ })++ // Ollama models are stored BARE (no `provider::` prefix) — that is what+ // getProviderIdFromModel falls back to, so these names are the real ones.+ it('a LOCAL model that rejects native tools falls back to the XML path', () => {+ // Prompt-injected <tool_call> is pure prompting, so a local model that+ // refused a `tools` payload can still drive the agent. This is how small+ // Ollama models have worked since 2.5.3 and must not regress.+ markToolsUnsupported('llama3.2:1b')+ expect(resolveToolSupport({ name: 'llama3.2:1b' })).toBe('hermes')+ expect(canUseTools({ name: 'llama3.2:1b' })).toBe(true)+ })++ it('an Ollama model off the agent-compatible list uses the XML path', () => {+ expect(resolveToolSupport({ name: 'mythomax:13b' })).toBe('hermes')+ })++ it('an Ollama model on the list does native', () => {+ expect(resolveToolSupport({ name: 'qwen3:8b' })).toBe('native')+ })++ it('an empty name is not tool-capable', () => {+ expect(resolveToolSupport({ name: '' })).toBe('none')+ expect(canUseTools({ name: '' })).toBe(false)+ })++ it('supportsTools true does not override a proven rejection for cloud', () => {+ // The cache is evidence from a real run; the flag is a claim. Evidence wins.+ markToolsUnsupported('lu-cloud::some-model')+ expect(resolveToolSupport({ name: 'lu-cloud::some-model', supportsTools: true })).toBe('none')+ })+})++describe('toolStrategyFor — the run gets the shape the UI promised', () => {+ it('sends native for a capable hosted model', () => {+ expect(toolStrategyFor({ name: 'lu-cloud::qwen3-32b' })).toBe('native')+ })++ it('never sends native for a model that already rejected it', () => {+ // The exact useCodex bug: non-Ollama providers were hardcoded to 'native',+ // so a declared-tool-less model got a `tools` payload every single run.+ markToolsUnsupported('openai::local-model')+ expect(toolStrategyFor({ name: 'openai::local-model' })).toBe('hermes_xml')+ })++ it('keeps the XML path for an off-list Ollama model', () => {+ expect(toolStrategyFor({ name: 'ollama::mythomax:13b' })).toBe('hermes_xml')+ })+})diff --git a/src/lib/model-compatibility.ts b/src/lib/model-compatibility.tsindex 477e58aa..1a0e1e4a 100644--- a/src/lib/model-compatibility.ts+++ b/src/lib/model-compatibility.ts@@ -63,7 +63,12 @@ function normalizeFamily(modelName: string): string {// slashes — the previous non-greedy strip left `trevorjs/...` behind and// the anchored dash-collapse below missed `gemma-4` entirely. Greedy fix// covers `hf.co/<user>/<repo>:<tag>`, `<user>/<repo>:<tag>`, and bare tags.- let s = modelName.toLowerCase().replace(/^.*\//, '')+ // Drop LU's `provider::` routing prefix first. Ollama models are stored bare+ // so this never used to matter, but every other provider prefixes, and the+ // `:tag` strip below would otherwise cut at the FIRST colon and reduce+ // `lu-cloud::qwen3-32b` to `lu-cloud` — every family check then silently+ // says no.+ let s = modelName.toLowerCase().replace(/^[a-z0-9_-]+::/, '').replace(/^.*\//, '')// Suffix markers — drop wherever they appears = s.replace(/-abliterated/g, '')diff --git a/src/lib/tool-support.ts b/src/lib/tool-support.tsnew file mode 100644index 00000000..84038ab1--- /dev/null+++ b/src/lib/tool-support.ts@@ -0,0 +1,91 @@+/**+ * One answer to "can this model use tools, and how" (2.5.9).+ *+ * Three signals existed and every surface combined them differently, so the+ * dropdown, the Agent toggle and the Code run could disagree about the same+ * model:+ *+ * 1. the reactive cache (api/tool-capability) — a run PROVED the model+ * rejects a `tools` payload (cloud 405, ollama "does not support tools")+ * 2. the server's own answer — LU Cloud `/models` returns `supports_tools`,+ * false for the roleplay and story models it hosts (Hermes 3, Euryale,+ * MythoMax, Llama 4 Maverick, …)+ * 3. the family-name heuristic in model-compatibility+ *+ * AgentModeToggle already layered 1 > 2 > 3 correctly. The chat dropdown used+ * a different pair for its icon, and useCodex used none of them: it hardcoded+ * `native` for every non-Ollama provider, so picking a declared-no-tools cloud+ * model in Code sent the request anyway, ate a 405, cached the negative, and+ * repeated the whole thing 24 h later when the negative expired.+ *+ * This module is that precedence, once, so all of them move together.+ */++import { getToolCapability } from '../api/tool-capability'+import { getToolCallingStrategy, isAgentCompatible, type ToolCallingStrategy } from './model-compatibility'+import { getProviderIdFromModel } from '../api/providers'++/**+ * How a model can call tools.+ * 'native' — OpenAI-style function calling in the request payload+ * 'hermes' — no native channel, but the prompt-injected <tool_call> XML+ * path can still drive it (small local models mostly land here)+ * 'none' — tools are off the table; Agent and Code cannot run on it+ */+export type ToolSupport = 'native' | 'hermes' | 'none'++export interface ToolSupportInput {+ /** The model id as the picker knows it (may carry a `provider::` prefix). */+ name: string+ /** `supports_tools` from the provider's own model list, when it says. */+ supportsTools?: boolean+}++export function resolveToolSupport({ name, supportsTools }: ToolSupportInput): ToolSupport {+ if (!name) return 'none'++ const provider = getProviderIdFromModel(name)+ const proven = getToolCapability(name)++ // A proven rejection and a server-declared `false` both mean the same thing:+ // do not put `tools` in the request. For a LOCAL model that is not the end of+ // it — the XML path is pure prompting and often still works, which is how+ // small Ollama models have driven the agent since 2.5.3. For a HOSTED model+ // it is the end of it: LU Cloud sets the flag on its story/roleplay models,+ // which will happily narrate a tool call instead of emitting one, and the+ // user pays per token to find that out.+ if (proven === 'unsupported' || supportsTools === false) {+ return provider === 'lu-cloud' ? 'none' : 'hermes'+ }++ // Nothing says no. Ollama still needs the family check (its catalogue is+ // full of base models with no tool template); everything else speaks the+ // OpenAI schema.+ if (provider === 'ollama') {+ return isAgentCompatible(name) ? 'native' : 'hermes'+ }+ return 'native'+}++/** Can this model drive Agent mode or the coding agent at all? */+export function canUseTools(input: ToolSupportInput): boolean {+ return resolveToolSupport(input) !== 'none'+}++/**+ * The strategy the run should actually use. Mirrors resolveToolSupport so a+ * model the UI offered as tool-capable never gets a request shape it already+ * told us it rejects. 'none' still returns 'hermes_xml' rather than throwing:+ * callers gate on canUseTools first, and a surprise here should degrade to the+ * weakest working path, not to a crash.+ */+export function toolStrategyFor(input: ToolSupportInput): ToolCallingStrategy {+ const support = resolveToolSupport(input)+ if (support === 'native') {+ // Preserve the template_fix branch the Ollama path relies on.+ return getProviderIdFromModel(input.name) === 'ollama'+ ? getToolCallingStrategy(input.name)+ : 'native'+ }+ return 'hermes_xml'+}