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.

feat(chat): curated web/file/image/video tools in plain chat (David 2026-06-11)

purplea68e49170e1b
diff --git a/src/components/chat/PluginsDropdown.tsx b/src/components/chat/PluginsDropdown.tsx
index 7f51064a..e6f068b9 100644
--- a/src/components/chat/PluginsDropdown.tsx
+++ b/src/components/chat/PluginsDropdown.tsx
@@ -1,5 +1,5 @@
import { useState } from 'react'
-import { Plug, ChevronDown, Bone, User } from 'lucide-react'
+import { Plug, ChevronDown, Bone, User, Wrench } from 'lucide-react'
import { useSettingsStore } from '../../stores/settingsStore'
import { useChatStore } from '../../stores/chatStore'
import type { CavemanMode } from '../../types/settings'
@@ -19,6 +19,10 @@ export function PluginsDropdown() {
const activePersona = getActivePersona()
const allPersonas = useSettingsStore((s) => s.personas)
const cavemanMode = useSettingsStore((s) => s.settings.cavemanMode)
+ // 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 updateSettings = useSettingsStore((s) => s.updateSettings)
// Per-chat persona enable/disable (mirrors mobile). Defaults to true
@@ -49,8 +53,9 @@ export function PluginsDropdown() {
>
<Plug size={10} />
<span>Plugins</span>
- {(isCavemanActive || isPersonaActive) && (
+ {(isCavemanActive || isPersonaActive || chatToolsEnabled) && (
<div className="flex gap-0.5">
+ {chatToolsEnabled && <div className="w-1 h-1 rounded-full bg-blue-400" />}
{isCavemanActive && <div className="w-1 h-1 rounded-full bg-amber-400" />}
{isPersonaActive && <div className="w-1 h-1 rounded-full bg-green-400" />}
</div>
@@ -63,6 +68,31 @@ export function PluginsDropdown() {
<div className="fixed inset-0 z-40" onClick={() => setOpen(false)} />
<div className="absolute right-0 top-full mt-1 z-50 w-56 rounded-lg bg-white dark:bg-[#262626] border border-gray-200 dark:border-white/10 shadow-xl py-1.5">
+ {/* ── Chat Tools toggle (v2.5.3) ──────────────── */}
+ <div className="px-2.5">
+ <div className="w-full flex items-center justify-between py-1.5 gap-2">
+ <div className="flex items-center gap-1.5 min-w-0">
+ <Wrench size={10} className={chatToolsEnabled ? 'text-blue-400' : 'text-gray-400'} />
+ <span className="text-[0.6rem] font-medium text-gray-600 dark:text-gray-300">Chat Tools</span>
+ <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'}
+ 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')
+ }
+ >
+ <span className="w-3 h-3 rounded-full bg-white shadow-sm mx-px" />
+ </button>
+ </div>
+ </div>
+
+ <div className="border-t border-gray-200 dark:border-white/[0.06] my-1" />
+
{/* ── Caveman Mode Dropdown ───────────────────── */}
<div className="px-2.5">
<button
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index f6c7fd17..72a59334 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -156,7 +156,15 @@ export function useAgentChat() {
// ── Main agent message handler ────────────────────────────
- const sendAgentMessage = useCallback(async (userContent: string, userImages?: import('../types/chat').ImageAttachment[]) => {
+ const sendAgentMessage = useCallback(async (
+ userContent: string,
+ userImages?: import('../types/chat').ImageAttachment[],
+ // Chat-Tools mode (David 2026-06-11): plain chat routes a tool-worthy turn
+ // here with a CURATED allow-list (the 5 chat tools) + a chat-style prompt,
+ // so web/file/image/video work without flipping to full Agent mode. When
+ // unset, this is the normal autonomous-agent path (full tool catalog).
+ opts?: { curatedTools?: readonly string[]; chatToolsMode?: boolean },
+ ) => {
const { activeModel } = useModelStore.getState()
const { settings } = useSettingsStore.getState()
const store = useChatStore.getState()
@@ -369,16 +377,28 @@ export function useAgentChat() {
// Get effective permissions for this conversation
const permissions = usePermissionStore.getState().getEffectivePermissions(convId!)
+ // Chat-Tools mode: restrict the catalog to the curated allow-list so the
+ // model in plain chat only ever sees the 5 chat tools (and small models
+ // aren't drowned in the full ~24-tool set).
+ const curated = opts?.curatedTools
+ const toolMatchesCurated = (name: string) => !curated || curated.includes(name)
+
// Build agent system prompt FIRST, then append caveman style as a modifier
const hermesToolDefs = toolRegistry.toHermesToolDefs(permissions)
+ .filter((t) => toolMatchesCurated(t.name))
// Small-Model Mode (Knob 2): swap the ~3000-char agent prompt for a lean
// ~750-char one on the native path. The Hermes-XML branch already uses a
// tight tool prompt (buildHermesToolPrompt), so it stays as-is.
+ // Chat-Tools mode uses a conversational prompt (NOT the autonomous-agent
+ // one) so plain chat keeps its normal voice and only reaches for a tool
+ // when the user actually needs it.
let agentSystemPrompt = strategy === 'hermes_xml'
? buildHermesToolPrompt(hermesToolDefs) + (systemPrompt ? `\n\n${systemPrompt}` : '')
- : settings.smallModelMode
- ? buildAgentSystemPromptLean(systemPrompt)
- : buildAgentSystemPrompt(systemPrompt)
+ : opts?.chatToolsMode
+ ? buildChatToolsSystemPrompt(systemPrompt)
+ : settings.smallModelMode
+ ? buildAgentSystemPromptLean(systemPrompt)
+ : buildAgentSystemPrompt(systemPrompt)
// Multi-Repo (Sprint C #8): when the agent workspace has extra paths,
// append a "Workspaces" section so the model can reference them by
@@ -576,7 +596,7 @@ export function useAgentChat() {
// permissive selection unchanged for big models.
const relevantDefs = await selectRelevantToolsAsync(
lastUserMsg,
- toolRegistry.getAll(),
+ toolRegistry.getAll().filter((t) => toolMatchesCurated(t.name)),
permissions,
settings.smallModelMode
? { embed: (texts) => generateEmbeddings(texts), topN: 5, embeddingThreshold: 6, maxTools: 6 }
@@ -1345,3 +1365,22 @@ Rules:
- When everything is done, reply with one short sentence in the user's language.`
return basePrompt ? `${lean}\n\n${basePrompt}` : lean
}
+
+/**
+ * Chat-Tools prompt (David 2026-06-11). Plain chat with a curated 5-tool set:
+ * the model stays a normal conversational assistant but CAN reach for a tool
+ * when the user actually needs one. Deliberately NOT the autonomous-agent
+ * "you MUST use tools / execute end-to-end" prompt — that would turn ordinary
+ * chat into an agent. Kept short so it doesn't crowd a small model's context.
+ */
+function buildChatToolsSystemPrompt(basePrompt: string): string {
+ const p = `You are a helpful chat assistant in Locally Uncensored, having a normal conversation. You also have a few tools for things you cannot do from memory — use one ONLY when the user's request actually needs it, otherwise just reply normally:
+- web_search — look up current/real-world facts (returns short snippets)
+- web_fetch — read a specific web page or URL (after a search, or when the user gives a link)
+- file_write — save text to a file when the user asks you to write/create/save a file
+- image_generate — create an image when the user asks for a picture/drawing/logo
+- video_generate — create a short video/animation when the user asks for one (to animate an image you just made, pass its filename as inputImage)
+
+Emit tool calls through the real tool channel — never as plain text like image_generate("…"). After a tool runs, give a short, natural reply about the result. For web questions, prefer web_search then web_fetch on the best result before answering. Reply in the user's language.`
+ return basePrompt ? `${p}\n\n${basePrompt}` : p
+}
diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.ts
index f1b63918..465a674c 100644
--- a/src/hooks/useChat.ts
+++ b/src/hooks/useChat.ts
@@ -12,6 +12,7 @@ import { effectiveContextWindow } from "../lib/context-window"
import { useAgentChat } from "./useAgentChat"
import { useMemory } from "./useMemory"
import { useAgentModeStore } from "../stores/agentModeStore"
+import { detectChatToolIntent, CHAT_TOOLS } from "../lib/chat-tool-intent"
import { getProviderForModel, getProviderIdFromModel } from "../api/providers"
import { syncOllamaHealthFromError } from "../lib/sync-ollama-health"
import { isThinkingCompatible, isPlainTextPlanner } from "../lib/model-compatibility"
@@ -45,6 +46,26 @@ export function useChat() {
return agentChat.sendAgentMessage(content, images)
}
+ // Chat-Tools routing (David 2026-06-11): web/file/image/video should work
+ // in PLAIN chat without flipping to full Agent mode. When the message
+ // clearly needs one of those capabilities, run THIS turn through the agent
+ // executor with a curated 5-tool allow-list + a chat-style prompt. Pure
+ // conversation falls through to the fast plain path below, untouched — so
+ // normal chatting (and the rikki/thought-only fixes) never regress.
+ const agentActiveHere = !!store.activeConversationId
+ && useAgentModeStore.getState().isActive(store.activeConversationId)
+ if (
+ activeModel
+ && settings.chatToolsEnabled !== false
+ && !agentActiveHere
+ && detectChatToolIntent(content, !!images?.length)
+ ) {
+ return agentChat.sendAgentMessage(content, images, {
+ curatedTools: CHAT_TOOLS,
+ chatToolsMode: true,
+ })
+ }
+
if (!activeModel) return
let convId = store.activeConversationId
diff --git a/src/lib/__tests__/chat-tool-intent.test.ts b/src/lib/__tests__/chat-tool-intent.test.ts
new file mode 100644
index 00000000..47e1ed3d
--- /dev/null
+++ b/src/lib/__tests__/chat-tool-intent.test.ts
@@ -0,0 +1,96 @@
+import { describe, it, expect } from 'vitest'
+import { detectChatToolCapability, detectChatToolIntent, CHAT_TOOLS } from '../chat-tool-intent'
+
+describe('detectChatToolCapability', () => {
+ it('exposes exactly the five curated tools', () => {
+ expect([...CHAT_TOOLS].sort()).toEqual(
+ ['file_write', 'image_generate', 'video_generate', 'web_fetch', 'web_search'].sort(),
+ )
+ })
+
+ describe('image', () => {
+ for (const p of [
+ 'draw me a picture of a red apple',
+ 'generate an image of a sunset over mountains',
+ 'make a logo for my coffee shop',
+ 'mal mir ein bild von einem hund',
+ 'erstelle eine grafik mit einem berg',
+ 'zeichne ein porträt einer katze',
+ ]) {
+ it(`image: "${p}"`, () => expect(detectChatToolCapability(p)).toBe('image'))
+ }
+ })
+
+ describe('video', () => {
+ for (const p of [
+ 'make a short video of waves at the beach',
+ 'generate a clip of a flying bird',
+ 'animate this image into a video',
+ 'erstelle ein video von einem wasserfall',
+ 'animier das bild',
+ ]) {
+ it(`video: "${p}"`, () => expect(detectChatToolCapability(p)).toBe('video'))
+ }
+
+ it('prefers video when both a video and image noun appear', () => {
+ expect(detectChatToolCapability('turn this picture into a short video')).toBe('video')
+ })
+
+ it('routes "animate" with an attached image to video', () => {
+ expect(detectChatToolCapability('animate this', true)).toBe('video')
+ })
+ })
+
+ describe('web', () => {
+ for (const p of [
+ 'search the web for the latest python version',
+ 'google who won the champions league final',
+ 'look up the current bitcoin price',
+ 'what is the weather in Berlin right now',
+ 'such im web nach den neuesten nvidia treibern',
+ 'recherchiere die aktuellen news zu KI',
+ 'summarize this page https://example.com/post',
+ 'open https://news.ycombinator.com and tell me the top story',
+ ]) {
+ it(`web: "${p}"`, () => expect(detectChatToolCapability(p)).toBe('web'))
+ }
+ })
+
+ describe('file', () => {
+ for (const p of [
+ 'write a file called notes.txt with my todo list',
+ 'save this to a file',
+ 'create a hello.html with a heading',
+ 'schreib eine datei mit dem text hallo',
+ 'speicher das als output.json',
+ 'export the result to a csv file',
+ ]) {
+ it(`file: "${p}"`, () => expect(detectChatToolCapability(p)).toBe('file'))
+ }
+ })
+
+ describe('plain conversation must NOT route (no false positives)', () => {
+ for (const p of [
+ 'hi there',
+ 'how are you today?',
+ 'explain how recursion works',
+ 'what is the capital of France',
+ 'tell me a joke',
+ 'can you help me understand quantum entanglement',
+ 'i like the picture you described earlier', // mentions "picture" but no create verb
+ 'thanks, that was helpful',
+ 'write a haiku about autumn', // "write" but no file noun/extension
+ 'make it shorter please',
+ 'what do you think about this idea',
+ 'summarize the conversation so far', // no page/url noun
+ ]) {
+ it(`plain: "${p}"`, () => expect(detectChatToolCapability(p)).toBeNull())
+ }
+ })
+
+ it('detectChatToolIntent is the boolean wrapper', () => {
+ expect(detectChatToolIntent('draw a cat')).toBe(true)
+ expect(detectChatToolIntent('hello')).toBe(false)
+ expect(detectChatToolIntent('')).toBe(false)
+ })
+})
diff --git a/src/lib/chat-tool-intent.ts b/src/lib/chat-tool-intent.ts
new file mode 100644
index 00000000..337af5f6
--- /dev/null
+++ b/src/lib/chat-tool-intent.ts
@@ -0,0 +1,107 @@
+/**
+ * Curated tools in PLAIN chat (David 2026-06-11: "web search web fetch file
+ * write und image und video mcp sollen auch im normalen chat funktionieren").
+ *
+ * Plain chat should be able to reach a small, fixed set of capabilities WITHOUT
+ * the user flipping the full Agent toggle. Rather than expose every agent tool
+ * on every message (which degrades pure conversation and over-triggers small
+ * models), we detect when a message clearly needs one of these five
+ * capabilities and route just that turn through the agent executor with a
+ * curated allow-list + a chat-style prompt. Everything else stays on the fast
+ * plain-chat path, untouched.
+ *
+ * The detector is intentionally capability-specific: a greeting, an
+ * explanation request, or normal Q&A must NOT match (otherwise every message
+ * would route through the tool loop). It errs toward the concrete signals a
+ * user gives when they actually want a web lookup, a file written, or an
+ * image/video made — in both English and German.
+ */
+
+/** The exact tools surfaced in plain chat. Order is irrelevant. */
+export const CHAT_TOOLS = [
+ 'web_search',
+ 'web_fetch',
+ 'file_write',
+ 'image_generate',
+ 'video_generate',
+] as const
+
+export type ChatToolCapability = 'image' | 'video' | 'web' | 'file'
+
+const lower = (s: string) => (s || '').toLowerCase()
+
+// A bare URL or an explicit "open/read this page" → web_fetch territory.
+const URL_RE = /\bhttps?:\/\/\S+|\bwww\.\S+|\b[a-z0-9-]+\.(com|org|net|io|dev|ai|de|co|gov|edu|app|news)\b(\/\S*)?/i
+const FETCH_VERB_RE = /\b(open|read|fetch|scrape|summari[sz]e|summari[sz]e|get|öffne|lies|lese|fasse|zusammenfass\w*|ruf\w*\s+auf)\b[^.?!]*\b(page|site|website|link|url|article|seite|webseite|link|url|artikel)\b/i
+
+// Search intent: explicit search verbs, or a freshness/lookup signal that a
+// model cannot answer reliably from training memory.
+const SEARCH_VERB_RE = /\b(search|google|look\s*up|web\s*search|search\s+the\s+web|such(e|en)?|google(n|st)?|recherchier\w*|nachschlagen|find\s+(online|on\s+the\s+web))\b/i
+// Freshness only triggers a search when it modifies a lookup-ish noun — bare
+// "today"/"now" in conversational phrasing ("how are you today") must not.
+const FRESHNESS_RE = /\b(latest|newest|current(ly)?|today'?s?|tonight|right\s+now|recent(ly)?|breaking|in\s+20\d\d|as\s+of\s+(today|now)|aktuell\w*|neueste\w*|heutige\w*)\b/i
+const FRESH_TOPIC_RE = /\b(version|release|update|news|results?|winner|champion|election|launch|price|prices|stock|standings|score|scores|ranking|patch|driver(s)?|model(s)?|treiber)\b/i
+const LOOKUP_TOPIC_RE = /\b(weather|temperature|forecast|price\s+of|stock\s+price|exchange\s+rate|who\s+won|who\s+is\s+winning|standings|release\s+date|wetter|preis\s+von|kurs\s+von|wer\s+hat\s+gewonnen|wechselkurs)\b/i
+
+// Verbs that inherently mean "make an image" even without a media noun
+// ("draw a cat", "zeichne eine Blume").
+const INHERENT_IMAGE_VERB_RE = /\b(draw|sketch|paint|illustrate|mal(e|en)?|zeichne(n|st)?|skizzier\w*)\b/i
+
+// Image / video creation: a creation verb co-occurring with a media noun.
+const CREATE_VERB_RE = /\b(draw|sketch|paint|generate|create|make|render|design|give\s+me|show\s+me|produce|turn|convert|mal(e|en)?|zeichne|erstell(e|en)?|generier(e|en)?|mach(e|en)?|gib\s+mir|zeig(e|en)?\s+mir|entwirf|produzier(e|en)?|verwandle|wandle)\b/i
+const IMAGE_NOUN_RE = /\b(image|picture|pic|photo(graph)?|drawing|art(work)?|illustration|portrait|wallpaper|logo|icon|render|painting|bild(er)?|foto(s)?|grafik(en)?|zeichnung(en)?|gem[äa]lde|portr[äa]t|illustration(en)?)\b/i
+const VIDEO_NOUN_RE = /\b(video|clip|animation|movie|gif|film|animier\w*|animate)\b/i
+const ANIMATE_RE = /\banimate\b[^.?!]*\b(image|picture|photo|it|this|that)\b|\banimier\w*\b[^.?!]*\b(bild|foto|es|das)\b/i
+
+// File creation: a write/save verb co-occurring with a file noun or an explicit
+// filename + extension.
+const FILE_VERB_RE = /\b(write|save|create|generate|put|export|dump|store|schreib(e|en)?|speicher(e|n|st)?|erstell(e|en)?|leg\w*\s+an|exportier(e|en)?|sichere)\b/i
+const FILE_NOUN_RE = /\b(a\s+|an\s+|the\s+|eine?\s+|die\s+)?(file|files|datei(en)?|textfile|text\s+file|markdown|csv|json\s+file)\b/i
+const FILENAME_RE = /\b[\w.-]+\.(txt|md|markdown|html?|css|js|ts|json|csv|xml|yaml|yml|py|sh|rs|toml|ini|log|svg|sql)\b/i
+const SAVE_TO_FILE_RE = /\b(save|write|export|dump|speicher\w*|schreib\w*)\b[^.?!]*\b(to|into|as|in)\b[^.?!]*\b(file|datei|disk|\.\w{1,5})\b/i
+
+/**
+ * Returns the capability a plain-chat message is asking for, or null if the
+ * message is ordinary conversation that should stay on the plain path.
+ * `hasImages` is true when the user attached an image — slightly biases the
+ * media branch toward video (animate-this-image) but is not required.
+ */
+export function detectChatToolCapability(text: string, hasImages = false): ChatToolCapability | null {
+ const t = lower(text).trim()
+ if (!t) return null
+
+ // VIDEO first (a video request often also contains an image-ish noun like
+ // "animate this picture into a video"; resolving video first avoids
+ // misrouting those to image generation).
+ if (CREATE_VERB_RE.test(t) && VIDEO_NOUN_RE.test(t)) return 'video'
+ if (ANIMATE_RE.test(t)) return 'video'
+ if (hasImages && /\b(animate|animier\w*|bring\s+to\s+life|make\s+it\s+move|in\s+ein\s+video)\b/i.test(t)) return 'video'
+
+ // IMAGE
+ if (CREATE_VERB_RE.test(t) && IMAGE_NOUN_RE.test(t)) return 'image'
+ if (INHERENT_IMAGE_VERB_RE.test(t)) return 'image'
+
+ // FILE WRITE
+ if (FILENAME_RE.test(t) && FILE_VERB_RE.test(t)) return 'file'
+ if (SAVE_TO_FILE_RE.test(t)) return 'file'
+ if (FILE_VERB_RE.test(t) && FILE_NOUN_RE.test(t)) return 'file'
+
+ // WEB FETCH (explicit page/url) — before generic search so a URL routes to
+ // fetch, not search.
+ if (FETCH_VERB_RE.test(t)) return 'web'
+ if (URL_RE.test(t) && /\b(open|read|fetch|summari[sz]e|get|check|visit|öffne|lies|lese|fasse|besuche|schau)\b/i.test(t)) return 'web'
+
+ // WEB SEARCH
+ if (SEARCH_VERB_RE.test(t)) return 'web'
+ if (LOOKUP_TOPIC_RE.test(t)) return 'web'
+ // Freshness only counts when it actually modifies a lookup-ish topic, so
+ // "what is the latest python version" routes but "how are you today" does not.
+ if (FRESHNESS_RE.test(t) && FRESH_TOPIC_RE.test(t)) return 'web'
+
+ return null
+}
+
+/** Convenience boolean wrapper for the router in useChat. */
+export function detectChatToolIntent(text: string, hasImages = false): boolean {
+ return detectChatToolCapability(text, hasImages) !== null
+}
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index d7c7ade3..335989ac 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -19,6 +19,10 @@ export const DEFAULT_SETTINGS: Settings = {
// Small-Model Mode (v2.5.0) — lean profile for 3B-8B local models.
// Default OFF: big models behave exactly as before until the user flips it.
smallModelMode: false,
+ // Chat-Tools (v2.5.3) — curated web/file/image/video tools in plain chat.
+ // Default ON so the capabilities "just work" without the Agent toggle; only
+ // tool-worthy messages route through the executor (see chat-tool-intent.ts).
+ chatToolsEnabled: true,
cavemanMode: 'off',
searchProvider: 'auto',
braveApiKey: '',
diff --git a/src/types/settings.ts b/src/types/settings.ts
index 84130012..764bf4b2 100644
--- a/src/types/settings.ts
+++ b/src/types/settings.ts
@@ -28,6 +28,16 @@ export interface Settings {
* Default false (big models are unaffected). Manual knob, not auto-forced.
*/
smallModelMode: boolean
+ /**
+ * Chat-Tools (v2.5.3, David 2026-06-11). When on (default), PLAIN chat can
+ * use a curated set of five tools — web_search, web_fetch, file_write,
+ * image_generate, video_generate — without the user flipping the full Agent
+ * toggle. A lightweight intent detector routes only tool-worthy messages
+ * through the agent executor with that restricted allow-list + a chat-style
+ * prompt; ordinary conversation stays on the plain path. Off = plain chat is
+ * pure text (the pre-v2.5.3 behaviour); the full Agent toggle still works.
+ */
+ chatToolsEnabled: boolean
cavemanMode: CavemanMode
searchProvider: SearchProvider
braveApiKey: string