Commit 97bbf98fd for llama.cpp

commit 97bbf98fdfeb311e50e313fc807d3af1a1ff32d4
Author: Aleksander Grygier <aleksander.grygier@gmail.com>
Date:   Tue Nov 24 15:00:46 2026 +0100

    ui: make Llama Chat a plain chat unless llama-server offers agent features (#32949)

    Llama Chat showed its tools, MCP and agentic settings and ran the agentic
    loop for every server. Now it does so only for a llama-server that offers
    its built-in tools or its proxy, which --agent turns on together; the app
    reads this from /props and /tools. Without them it is a plain chat: a
    message and its reply, with reasoning when the model gives it. The chat
    store sends the classic request, the tools store has no tools and the MCP
    store connects to no server, so the tools menu, the working folder, the MCP
    entry and page, and the Tools and Agentic settings are gone. Tool calls in
    earlier conversations still display.

    The Show MCP setting moves from General to the Agentic settings, with the
    rest of what agent mode adds.

    VITE_PUBLIC_AGENTIC=false builds an app that is a plain chat for every
    server, and leaves Llama Harness's loop out of the bundle: the harness gets
    a ./trace entry with the phrasing alone, and Vite resolves the package to a
    small stub that re-exports it. A CI job builds the variant and checks the
    loop is not in it.

    Assisted-by: Claude (Opus 5.5 Medium)

diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml
index bba032416..3547bf4c6 100644
--- a/.github/workflows/ui.yml
+++ b/.github/workflows/ui.yml
@@ -212,6 +212,38 @@ jobs:
         run: npm run prepack
         working-directory: ui/lib/harness

+  chat-only-build:
+    name: Chat-only build
+    runs-on: ubuntu-24.04
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v6
+        with:
+          ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v6
+        with:
+          node-version: "24"
+          package-manager-cache: false
+
+      - name: Install dependencies
+        run: npm ci
+        working-directory: ui/apps/chat
+
+      - name: Build without the agentic loop
+        run: npm run build
+        working-directory: ui/apps/chat
+        env:
+          VITE_PUBLIC_AGENTIC: "false"
+
+      - name: Check the harness loop is not in the bundle
+        run: |
+          if grep -rlq "Tool execution was interrupted by a new user message" dist; then
+            echo "The chat-only bundle contains Llama Harness's loop" && exit 1
+          fi
+        working-directory: ui/apps/chat
+
   e2e-tests:
     name: E2E Tests
     needs: ui-build
diff --git a/ui/apps/chat/.env.example b/ui/apps/chat/.env.example
index 9760b0dd4..269e65278 100644
--- a/ui/apps/chat/.env.example
+++ b/ui/apps/chat/.env.example
@@ -1,4 +1,6 @@
 VITE_PUBLIC_APP_NAME='Llama Chat'
+# 'false' builds a chat-only app: no tools, no MCP, no agentic loop
+# VITE_PUBLIC_AGENTIC='false'
 VITE_DEBUG='true'
 VITE_PUBLIC_SERVER_ORIGIN='http://localhost:8033'

diff --git a/ui/apps/chat/.storybook/preview.ts b/ui/apps/chat/.storybook/preview.ts
index 22f04dd88..47c884fd0 100644
--- a/ui/apps/chat/.storybook/preview.ts
+++ b/ui/apps/chat/.storybook/preview.ts
@@ -1,5 +1,6 @@
 import '../src/app.css';
 import { MEDIA_QUERIES } from '#lib/constants/pwa.constants.ts';
+import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 // the docs pages' styles, shared with the library's Storybook
 import '../../../lib/ui/.storybook/docs.css';
 import { applyColorScheme } from './color-scheme';
@@ -7,6 +8,9 @@ import ModeWatcherDecorator from './decorators/ModeWatcherDecorator.svelte';
 import TooltipProviderDecorator from './decorators/TooltipProviderDecorator.svelte';
 import type { Preview } from '@storybook/sveltekit';

+// the stories show the app as with a llama-server started with --agent
+agenticMode.serverHasTools = true;
+
 applyColorScheme();
 window.matchMedia(MEDIA_QUERIES.PREFERS_DARK).addEventListener('change', applyColorScheme);

diff --git a/ui/apps/chat/README.md b/ui/apps/chat/README.md
index 891fe6b2a..6ba2e8957 100644
--- a/ui/apps/chat/README.md
+++ b/ui/apps/chat/README.md
@@ -154,6 +154,10 @@ llama-server serves the UI with `Cross-Origin-Embedder-Policy: require-corp` and

 llama-server embeds it: when llama-server is built, `scripts/ui-assets.cmake` takes `ui/apps/chat/dist` if it exists, runs `npm run build` if `LLAMA_BUILD_UI` is on, or downloads the release's prebuilt `dist.tar.gz` from Hugging Face, and compiles every file into the binary. The same `dist` is what `npx @ggml-org/llama-chat` serves.

+**Plain chat and agent mode.** Llama Chat is a plain chat, a message and its reply with reasoning when the model gives it, unless llama-server offers the agentic features: its built-in tools or its proxy, which `llama-server --agent` turns on together. The app reads this from `/props` and `/tools`. With them it shows the tools menu, the working folder, MCP and the Tools and Agentic settings, and runs the agentic loop; without them it shows none of these and sends the classic request. Tool calls in earlier conversations still display.
+
+**Chat-only build.** `VITE_PUBLIC_AGENTIC=false npm run build` builds an app that is a plain chat for every server, and `npm run dev:chat-only` runs the dev server the same way. Llama Harness's loop is left out of its bundle.
+
 ```text
 ui/apps/chat/
 ├── src/
diff --git a/ui/apps/chat/package.json b/ui/apps/chat/package.json
index bc3f0d331..76146f41e 100644
--- a/ui/apps/chat/package.json
+++ b/ui/apps/chat/package.json
@@ -43,6 +43,7 @@
 		"build": "npm run build-pwa-assets && vite build",
 		"build-pwa-assets": "pwa-assets-generator --root . --config pwa-assets.config.ts && pwa-assets-generator --root . --config pwa-assets-dark.config.ts && node scripts/make-icons-circular.js",
 		"dev": "bash scripts/dev.sh",
+		"dev:chat-only": "VITE_PUBLIC_AGENTIC=false bash scripts/dev.sh",
 		"preview": "vite preview",
 		"prepare": "svelte-kit sync || echo ''",
 		"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte
index e25bcb56f..11c8a1954 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte
@@ -2,7 +2,8 @@
 	import { Button } from '@ggml-org/llama-ui/ui/button';
 	import * as Tooltip from '@ggml-org/llama-ui/ui/tooltip';
 	import { Plus } from '@lucide/svelte';
-	import { ATTACHMENT_TOOLTIP_TEXT, ICON_CLASS_DEFAULT } from '#lib/constants/index.ts';
+	import { attachmentTooltipText, ICON_CLASS_DEFAULT } from '#lib/constants/index.ts';
+	import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';

 	interface Props {
 		disabled?: boolean;
@@ -21,13 +22,13 @@
 			type="button"
 			variant="ghost"
 		>
-			<span class="sr-only">{ATTACHMENT_TOOLTIP_TEXT}</span>
+			<span class="sr-only">{attachmentTooltipText(agenticMode.enabled)}</span>

 			<Plus class={ICON_CLASS_DEFAULT} />
 		</Button>
 	</Tooltip.Trigger>

 	<Tooltip.Content>
-		<p>{ATTACHMENT_TOOLTIP_TEXT}</p>
+		<p>{attachmentTooltipText(agenticMode.enabled)}</p>
 	</Tooltip.Content>
 </Tooltip.Root>
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte
index 78153bfbd..d86d663f3 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte
@@ -9,13 +9,14 @@
 		ATTACHMENT_FILE_ITEMS,
 		ATTACHMENT_MENU_TEXT,
 		ATTACHMENT_MODALITY_TEXT,
-		ATTACHMENT_TOOLTIP_TEXT,
+		attachmentTooltipText,
 		ICON_CLASS_DEFAULT,
 		MODALITY_ICONS
 	} from '#lib/constants/index.ts';
 	import { getChatFormActionsContext } from '#lib/contexts/index.ts';
 	import { AttachmentAction, AttachmentItemEnabledWhen, ModelModality } from '#lib/enums/index.ts';
 	import { useAttachmentMenu } from '#lib/hooks/use-attachment-menu.svelte.ts';
+	import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 	import type { Component } from 'svelte';

 	interface Props {
@@ -84,7 +85,7 @@
 						)}
 						disabled={chatFormActions.disabled}
 					>
-						<span class="sr-only">{ATTACHMENT_TOOLTIP_TEXT}</span>
+						<span class="sr-only">{attachmentTooltipText(agenticMode.enabled)}</span>

 						<Plus class={ICON_CLASS_DEFAULT} />
 					</DropdownMenu.Trigger>
@@ -92,7 +93,7 @@
 			</Tooltip.Trigger>

 			<Tooltip.Content>
-				<p>{ATTACHMENT_TOOLTIP_TEXT}</p>
+				<p>{attachmentTooltipText(agenticMode.enabled)}</p>
 			</Tooltip.Content>
 		</Tooltip.Root>

@@ -160,7 +161,9 @@
 				</DropdownMenu.Item>
 			{/if}

-			<ChatFormActionAddToolsSubmenu />
+			{#if agenticMode.enabled}
+				<ChatFormActionAddToolsSubmenu />
+			{/if}
 		</DropdownMenu.Content>
 	</DropdownMenu.Root>
 </div>
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
index 9a241af28..80d0cb5fd 100644
--- a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte
@@ -22,7 +22,7 @@
 		ICON_CLASS_SM,
 		ICON_CLASS_XS,
 		SIDEBAR_ACTIONS_ITEMS,
-		SIDEBAR_FOOTER_ITEMS
+		sidebarFooterItems
 	} from '#lib/constants/index.ts';
 	import { KeyboardKey, SidebarAction } from '#lib/enums/index.ts';
 	import { useDebouncedSearch } from '#lib/hooks/use-debounced-search.svelte.ts';
@@ -32,6 +32,7 @@
 		HuggingFaceService
 	} from '#lib/services/index.ts';
 	import { RouterService } from '#lib/services/router.service.ts';
+	import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 	import {
 		conversationsStore,
 		deviceStore,
@@ -248,7 +249,7 @@
 	const actionEntries = $derived.by((): SearchEntry[] =>
 		// every sidebar action the sidebar shows but Search itself, which is what opened this
 		// dialog, and the models manager on a phone, which picks its models in the selector
-		[...SIDEBAR_ACTIONS_ITEMS, ...SIDEBAR_FOOTER_ITEMS]
+		[...SIDEBAR_ACTIONS_ITEMS, ...sidebarFooterItems(agenticMode.enabled)]
 			.filter(
 				(item) =>
 					item.action &&
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
index 4ca101874..ebbc539f6 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte
@@ -22,18 +22,19 @@
 		SIDEBAR_COLLAPSE_WIDTH,
 		SIDEBAR_COLLAPSED_WIDTH,
 		SIDEBAR_CONTENT_FADE_MS,
-		SIDEBAR_FOOTER_ITEMS,
 		SIDEBAR_MAX_WIDTH,
 		SIDEBAR_MIN_WIDTH,
 		SIDEBAR_OVERSTRETCH_PX,
 		SIDEBAR_REVEAL_ACTION_DELAY_MS,
 		SIDEBAR_SETTLE_MS,
-		SIDEBAR_TOGGLE_MS
+		SIDEBAR_TOGGLE_MS,
+		sidebarFooterItems
 	} from '#lib/constants/index.ts';
 	import { SidebarAction, TooltipSide } from '#lib/enums/index.ts';
 	import { useKeyboardShortcuts } from '#lib/hooks/use-keyboard-shortcuts.svelte.ts';
 	import { useMarqueeSelection } from '#lib/hooks/use-marquee-selection.svelte.ts';
 	import { RouterService } from '#lib/services/router.service.ts';
+	import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 	import {
 		chatStore,
 		conversationsStore,
@@ -668,7 +669,9 @@
 				<!-- a phone has no footer: its items join these -->
 				<SidebarNavigationActions
 					class="px-2 md:my-3"
-					items={isOnMobile ? [...SIDEBAR_ACTIONS_ITEMS, ...SIDEBAR_FOOTER_ITEMS] : undefined}
+					items={isOnMobile
+						? [...SIDEBAR_ACTIONS_ITEMS, ...sidebarFooterItems(agenticMode.enabled)]
+						: undefined}
 					onAction={handleSidebarAction}
 					onNavigate={navigateBehind}
 				/>
diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte
index b236dc3db..714d0f646 100644
--- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte
+++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte
@@ -1,7 +1,8 @@
 <script lang="ts">
 	import SidebarNavigationActions from './SidebarNavigationActions.svelte';
-	import { SIDEBAR_FOOTER_ITEMS } from '#lib/constants/index.ts';
+	import { sidebarFooterItems } from '#lib/constants/index.ts';
 	import type { SidebarAction } from '#lib/enums/index.ts';
+	import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';

 	interface Props {
 		onAction?: (action: SidebarAction) => void;
@@ -14,6 +15,6 @@
      rounded concentric with it (see the nested surfaces in app.css) -->
 <SidebarNavigationActions
 	class="inset-group-surface mx-2 mb-2 p-(--surface-group-padding)"
-	items={SIDEBAR_FOOTER_ITEMS}
+	items={sidebarFooterItems(agenticMode.enabled)}
 	{onAction}
 />
diff --git a/ui/apps/chat/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte b/ui/apps/chat/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte
index fd058cea6..17b00e974 100644
--- a/ui/apps/chat/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte
+++ b/ui/apps/chat/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte
@@ -14,11 +14,12 @@
 	import {
 		NUMERIC_FIELDS,
 		POSITIVE_INTEGER_FIELDS,
-		SETTINGS_CHAT_SECTIONS,
 		SETTINGS_KEYS,
-		SETTINGS_SECTION_SLUGS
+		SETTINGS_SECTION_SLUGS,
+		settingsChatSections
 	} from '#lib/constants/index.ts';
 	import { ColorMode } from '#lib/enums/ui.enums.ts';
+	import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 	import { modelsStore, serverStore, settingsStore } from '#lib/stores/index.ts';
 	import type { SettingsSection, SettingsSectionTitle } from '#lib/types/index.ts';
 	import { setMode } from 'mode-watcher';
@@ -33,10 +34,12 @@

 	let { initialSection, mobileHeaderClass, onClose, onSectionChange }: Props = $props();

+	const sections = $derived(settingsChatSections(agenticMode.enabled));
+
 	let activeSlug = $derived(initialSection ?? 'general');

 	function handleSectionChange(section: SettingsSectionTitle) {
-		const found = SETTINGS_CHAT_SECTIONS.find((s) => s.title === section);
+		const found = sections.find((s) => s.title === section);

 		if (found) {
 			activeSlug = found.slug;
@@ -46,8 +49,7 @@
 	}

 	let currentSection = $derived(
-		SETTINGS_CHAT_SECTIONS.find((section) => section.slug === activeSlug) ||
-			SETTINGS_CHAT_SECTIONS[0]
+		sections.find((section) => section.slug === activeSlug) || sections[0]
 	);

 	let localConfig: SettingsConfigType = $state({ ...settingsStore.config });
@@ -131,9 +133,9 @@

 				if (!isNaN(numValue)) {
 					if ((POSITIVE_INTEGER_FIELDS as readonly string[]).includes(field)) {
-						const entryByMinMax = SETTINGS_CHAT_SECTIONS.flatMap(
-							(section) => section.fields ?? []
-						).find((entry) => entry.key === field);
+						const entryByMinMax = sections
+							.flatMap((section) => section.fields ?? [])
+							.find((entry) => entry.key === field);
 						const lo = entryByMinMax?.min ?? 1;
 						const hi = entryByMinMax?.max ?? Number.POSITIVE_INFINITY;

@@ -163,7 +165,7 @@
 		<SettingsChatDesktopSidebar
 			isActive={(section: SettingsSection) => section.slug === activeSlug}
 			onSectionChange={handleSectionChange}
-			sections={SETTINGS_CHAT_SECTIONS}
+			{sections}
 		/>

 		<SettingsChatMobileHeader
@@ -171,7 +173,7 @@
 			class={mobileHeaderClass}
 			isActive={(section: SettingsSection) => section.slug === activeSlug}
 			onSectionChange={handleSectionChange}
-			sections={SETTINGS_CHAT_SECTIONS}
+			{sections}
 		/>

 		<div class="mx-auto max-w-2xl px-4 flex-1 md:mt-4">
diff --git a/ui/apps/chat/src/lib/constants/app.constants.ts b/ui/apps/chat/src/lib/constants/app.constants.ts
index 8e87264c3..d6d15e073 100644
--- a/ui/apps/chat/src/lib/constants/app.constants.ts
+++ b/ui/apps/chat/src/lib/constants/app.constants.ts
@@ -1 +1,10 @@
 export const APP_NAME = import.meta.env?.VITE_PUBLIC_APP_NAME || 'Llama Chat';
+
+/**
+ * False in a chat-only build (`VITE_PUBLIC_AGENTIC=false`): no tools, no MCP and
+ * no agentic loop, only a message and its reply. Such a build leaves Llama
+ * Harness's loop out of the bundle (see vite.config.ts). A full build still
+ * turns the agentic features on only for a server that offers them: read
+ * `agenticMode.enabled`, not this constant, to decide what to show.
+ */
+export const AGENTIC_ENABLED = import.meta.env?.VITE_PUBLIC_AGENTIC !== 'false';
diff --git a/ui/apps/chat/src/lib/constants/attachment-menu.constants.ts b/ui/apps/chat/src/lib/constants/attachment-menu.constants.ts
index 288845776..830f2f190 100644
--- a/ui/apps/chat/src/lib/constants/attachment-menu.constants.ts
+++ b/ui/apps/chat/src/lib/constants/attachment-menu.constants.ts
@@ -56,7 +56,10 @@ export const ATTACHMENT_FILE_ITEMS: AttachmentMenuItem[] = [
 	}
 ];

-export const ATTACHMENT_TOOLTIP_TEXT = 'Add files, prompts, tools or MCP Servers';
+/** What the add button offers: tools and MCP servers only with the agentic features on. */
+export function attachmentTooltipText(agentic: boolean): string {
+	return agentic ? 'Add files, prompts, tools or MCP Servers' : 'Add files or prompts';
+}

 /** Text shared by the add menu's two surfaces: the desktop dropdown and the mobile drawer. */
 export const ATTACHMENT_MENU_TEXT = {
diff --git a/ui/apps/chat/src/lib/constants/settings.constants.ts b/ui/apps/chat/src/lib/constants/settings.constants.ts
index 8182fb372..c64cfca50 100644
--- a/ui/apps/chat/src/lib/constants/settings.constants.ts
+++ b/ui/apps/chat/src/lib/constants/settings.constants.ts
@@ -162,13 +162,6 @@ export const SETTINGS_REGISTRY: SettingsSectionEntry[] = [
 				label: 'Use the Hugging Face Hub API',
 				type: SettingsFieldType.CHECKBOX
 			},
-			{
-				defaultValue: false,
-				help: 'Show MCP in the sidebar, to add and manage MCP servers. Servers already added keep working while it is hidden.',
-				key: SETTINGS_KEYS.SHOW_MCP,
-				label: 'Show MCP',
-				type: SettingsFieldType.CHECKBOX
-			},
 			{
 				defaultValue: true,
 				help: 'Choose how conversation titles are generated. The first non-empty line uses a fast deterministic rule; the LLM option uses a model-generated title from the first message exchange.',
@@ -530,6 +523,13 @@ export const SETTINGS_REGISTRY: SettingsSectionEntry[] = [
 	{
 		icon: ListRestart,
 		settings: [
+			{
+				defaultValue: false,
+				help: 'Show MCP in the sidebar, to add and manage MCP servers. Servers already added keep working while it is hidden.',
+				key: SETTINGS_KEYS.SHOW_MCP,
+				label: 'Show MCP',
+				type: SettingsFieldType.CHECKBOX
+			},
 			{
 				defaultValue: DEFAULT_AGENTIC_CONFIG.maxTurns,
 				help: 'Maximum number of tool execution cycles before stopping (prevents infinite loops).',
@@ -882,6 +882,17 @@ function toSettingsSection(section: SettingsSectionEntry): SettingsSection {
 /** Sidebar sections in custom display order (the registry array order). */
 export const SETTINGS_CHAT_SECTIONS: SettingsSection[] = SETTINGS_REGISTRY.map(toSettingsSection);

+/** The sections to show: without the agentic features there are no tools, no loop and no MCP to set up, which are all in Tools and Agentic. */
+export function settingsChatSections(agentic: boolean): SettingsSection[] {
+	if (agentic) return SETTINGS_CHAT_SECTIONS;
+
+	return SETTINGS_CHAT_SECTIONS.filter(
+		(section) =>
+			section.slug !== SETTINGS_SECTION_SLUGS.TOOLS &&
+			section.slug !== SETTINGS_SECTION_SLUGS.AGENTIC
+	);
+}
+
 /** INPUT-type settings whose value is a number. */
 export const NUMERIC_FIELDS = getAllSettings()
 	.filter((s) => s.type === SettingsFieldType.INPUT && typeof s.defaultValue !== 'string')
diff --git a/ui/apps/chat/src/lib/constants/ui.constants.ts b/ui/apps/chat/src/lib/constants/ui.constants.ts
index 05198a344..a371aec8d 100644
--- a/ui/apps/chat/src/lib/constants/ui.constants.ts
+++ b/ui/apps/chat/src/lib/constants/ui.constants.ts
@@ -188,5 +188,12 @@ export const SIDEBAR_FOOTER_ITEMS: DesktopIconStripItem[] = [
 	}
 ];

+/** The footer items to show: without the agentic features there is no MCP. */
+export function sidebarFooterItems(agentic: boolean): DesktopIconStripItem[] {
+	return agentic
+		? SIDEBAR_FOOTER_ITEMS
+		: SIDEBAR_FOOTER_ITEMS.filter((item) => item.action !== SidebarAction.MCP);
+}
+
 /** A light haptic tap's length where the browser vibrates (Android): a click, not a buzz. */
 export const HAPTIC_TAP_MS = 8;
diff --git a/ui/apps/chat/src/lib/stores/agentic-mode.svelte.ts b/ui/apps/chat/src/lib/stores/agentic-mode.svelte.ts
new file mode 100644
index 000000000..d31d664dd
--- /dev/null
+++ b/ui/apps/chat/src/lib/stores/agentic-mode.svelte.ts
@@ -0,0 +1,35 @@
+/**
+ * agenticMode - Whether the agentic features are on
+ *
+ * They are on when the build has them (see AGENTIC_ENABLED) and llama-server
+ * offers what they need: its built-in tools or its proxy, which `--agent`
+ * turns on together. Without them Llama Chat is a plain chat: a message and
+ * its reply, with no tools, no MCP and no agentic loop.
+ *
+ * The server says so in two places: `/props` reports the proxy, and `/tools`
+ * lists the built-in tools, which the tools store reports here.
+ */
+
+import { AGENTIC_ENABLED } from '#lib/constants/app.constants.ts';
+import { serverStore } from '#lib/stores/llama-server.svelte.ts';
+
+class AgenticMode {
+	/** Set by the tools store once the server has listed its built-in tools. */
+	serverHasTools = $state(false);
+
+	/** Set by the tools store once the server has answered about its tools, either way. */
+	serverToolsKnown = $state(false);
+
+	get enabled(): boolean {
+		return (
+			AGENTIC_ENABLED && (this.serverHasTools || (serverStore.props?.cors_proxy_enabled ?? false))
+		);
+	}
+
+	/** True once the server has said what it offers, so a page can act on `enabled` being false. */
+	get settled(): boolean {
+		return !AGENTIC_ENABLED || (serverStore.props !== null && this.serverToolsKnown);
+	}
+}
+
+export const agenticMode = new AgenticMode();
diff --git a/ui/apps/chat/src/lib/stores/agentic/harness-chat-only.ts b/ui/apps/chat/src/lib/stores/agentic/harness-chat-only.ts
new file mode 100644
index 000000000..b08caf467
--- /dev/null
+++ b/ui/apps/chat/src/lib/stores/agentic/harness-chat-only.ts
@@ -0,0 +1,10 @@
+// What `@ggml-org/llama-harness` resolves to in a chat-only build
+// (VITE_PUBLIC_AGENTIC=false, see vite.config.ts): the trace phrasing, which
+// still draws the tool calls of conversations made by a full build, and no
+// loop. The chat store never starts a flow in such a build.
+
+export * from '@ggml-org/llama-harness/trace';
+
+export function createHarness(): never {
+	throw new Error('This build of Llama Chat has no agentic loop.');
+}
diff --git a/ui/apps/chat/src/lib/stores/chat/index.svelte.ts b/ui/apps/chat/src/lib/stores/chat/index.svelte.ts
index 20c95be39..07207a488 100644
--- a/ui/apps/chat/src/lib/stores/chat/index.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/chat/index.svelte.ts
@@ -25,8 +25,9 @@ import {
 } from '#lib/enums/index.ts';
 import { ChatService } from '#lib/services/chat.service.ts';
 import { DatabaseService } from '#lib/services/database.service.ts';
-// direct imports between stores, not via the barrel, to avoid circular deps
 import { agenticStore } from '#lib/stores/agentic/index.svelte.ts';
+// direct imports between stores, not via the barrel, to avoid circular deps
+import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 import { chatActivityStore } from '#lib/stores/chat/activity.svelte.ts';
 import { type ChatFlowsHost, ChatMessageFlows } from '#lib/stores/chat/flows.svelte.ts';
 import { chatProcessingStore } from '#lib/stores/chat/processing.svelte.ts';
@@ -1258,7 +1259,8 @@ class ChatStore implements ChatStreamHost, ChatFlowsHost {
 		};
 		const toolPolicy = this.toolPolicy();

-		{
+		// a plain chat sends the classic request below
+		if (agenticMode.enabled) {
 			const agenticResult = await agenticStore.runAgenticFlow({
 				callbacks: streamCallbacks,
 				conversationId: convId,
diff --git a/ui/apps/chat/src/lib/stores/mcp/index.svelte.ts b/ui/apps/chat/src/lib/stores/mcp/index.svelte.ts
index 8b9536769..55aef252a 100644
--- a/ui/apps/chat/src/lib/stores/mcp/index.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/mcp/index.svelte.ts
@@ -19,6 +19,7 @@ import {
 } from '#lib/constants/index.ts';
 import { ColorMode, HealthCheckStatus, MCPConnectionPhase, MCPRefType } from '#lib/enums/index.ts';
 import { MCPService } from '#lib/services/mcp.service.ts';
+import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 import { serverStore } from '#lib/stores/llama-server.svelte.ts';
 // direct imports between stores, not via the barrel, to avoid circular deps
 import { MCPHealthCheckManager, type McpHealthHost } from '#lib/stores/mcp/health.svelte.ts';
@@ -736,6 +737,9 @@ class MCPStore implements McpHealthHost {
 	}

 	getServers(): MCPServerSettingsEntry[] {
+		// a plain chat keeps the saved servers and connects to none
+		if (!agenticMode.enabled) return [];
+
 		const raw = settingsStore.config.mcpServers;

 		// cache the parse: the config string rarely changes and getServers is
diff --git a/ui/apps/chat/src/lib/stores/tools.svelte.ts b/ui/apps/chat/src/lib/stores/tools.svelte.ts
index 99b65a187..63610112c 100644
--- a/ui/apps/chat/src/lib/stores/tools.svelte.ts
+++ b/ui/apps/chat/src/lib/stores/tools.svelte.ts
@@ -7,6 +7,7 @@
  * the chat flows.
  */

+import { AGENTIC_ENABLED } from '#lib/constants/app.constants.ts';
 import {
 	buildBrowserInfoToolDefinition,
 	buildGetDatetimeToolDefinition,
@@ -27,6 +28,7 @@ import {
 	ToolSource
 } from '#lib/enums/index.ts';
 import { ToolsService } from '#lib/services/tools.service.ts';
+import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 // direct imports between stores, not via the barrel, to avoid circular deps
 import { mcpStore } from '#lib/stores/mcp/index.svelte.ts';
 import { modelsStore } from '#lib/stores/models/index.svelte.ts';
@@ -58,6 +60,8 @@ class ToolsStore {

 	/** Canonical flat list of tool entries with source metadata and stable keys, deduped by key */
 	get allTools(): ToolEntry[] {
+		if (!agenticMode.enabled) return [];
+
 		const entries: ToolEntry[] = [];
 		const seen = new SvelteSet<string>();
 		const push = (entry: ToolEntry) => {
@@ -233,7 +237,7 @@ class ToolsStore {
 	}

 	async fetchServerTools(): Promise<void> {
-		if (this._loading) return;
+		if (!AGENTIC_ENABLED || this._loading) return;

 		this._loading = true;
 		this._error = null;
@@ -243,6 +247,7 @@ class ToolsStore {
 			const toolInfos = await ToolsService.list();

 			this._serverTools = toolInfos.map((info) => info.definition);
+			agenticMode.serverHasTools = toolInfos.length > 0;
 			this.cwdAwareTools = new SvelteSet(
 				toolInfos.filter((info) => info.uses_cwd).map((info) => info.tool)
 			);
@@ -258,6 +263,7 @@ class ToolsStore {
 			}
 		} finally {
 			this._loading = false;
+			agenticMode.serverToolsKnown = true;
 		}
 	}

@@ -431,6 +437,9 @@ class ToolsStore {
 	async resolveServerHome(): Promise<string | null> {
 		if (this._serverHome !== undefined) return this._serverHome;

+		// a plain chat never calls the server's tools
+		if (!agenticMode.enabled) return null;
+
 		try {
 			const res = await ToolsService.executeToolRaw(BuiltInTool.SERVER_FILE_GLOB_SEARCH, {
 				limit: 1,
diff --git a/ui/apps/chat/src/routes/mcp-servers/+page.svelte b/ui/apps/chat/src/routes/mcp-servers/+page.svelte
index f2733f621..f29eb9318 100644
--- a/ui/apps/chat/src/routes/mcp-servers/+page.svelte
+++ b/ui/apps/chat/src/routes/mcp-servers/+page.svelte
@@ -1,6 +1,13 @@
 <script lang="ts">
 	import { SettingsMcpServers } from '#lib/components/app/settings/index.ts';
-	import { APP_NAME } from '#lib/constants/index.ts';
+	import { APP_NAME, ROUTES } from '#lib/constants/index.ts';
+	import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
+	import { goto } from '$app/navigation';
+
+	// a server without the agentic features has no MCP
+	$effect(() => {
+		if (agenticMode.settled && !agenticMode.enabled) void goto(ROUTES.START);
+	});
 </script>

 <svelte:head>
diff --git a/ui/apps/chat/src/routes/mcp-servers/+page.ts b/ui/apps/chat/src/routes/mcp-servers/+page.ts
index 3c3deac51..76161de87 100644
--- a/ui/apps/chat/src/routes/mcp-servers/+page.ts
+++ b/ui/apps/chat/src/routes/mcp-servers/+page.ts
@@ -1,4 +1,11 @@
 import type { PageLoad } from './$types';
+import { redirect } from '@sveltejs/kit';
+import { AGENTIC_ENABLED, ROUTES } from '#lib/constants/index.ts';
 import { loadAppRoute } from '#lib/stores/init.ts';

-export const load: PageLoad = ({ fetch }) => loadAppRoute(fetch);
+export const load: PageLoad = ({ fetch }) => {
+	// a chat-only build has no MCP
+	if (!AGENTIC_ENABLED) redirect(307, ROUTES.START);
+
+	return loadAppRoute(fetch);
+};
diff --git a/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte b/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte
index b1058822a..ad443f61c 100644
--- a/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte
+++ b/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte
@@ -1,7 +1,7 @@
 <script lang="ts" module>
 	import { defineMeta } from '@storybook/addon-svelte-csf';
 	import ChatScreenForm from '#lib/components/app/chat/ChatScreen/ChatScreenForm.svelte';
-	import { ATTACHMENT_TOOLTIP_TEXT } from '#lib/constants/index.ts';
+	import { attachmentTooltipText } from '#lib/constants/index.ts';
 	import { expect, screen, waitFor } from 'storybook/test';

 	const { Story } = defineMeta({
@@ -23,7 +23,7 @@
 		await userEvent.clear(editor);
 		await userEvent.type(editor, 'What is the meaning of life?');

-		const trigger = await canvas.findByRole('button', { name: ATTACHMENT_TOOLTIP_TEXT });
+		const trigger = await canvas.findByRole('button', { name: attachmentTooltipText(true) });

 		trigger.focus();
 		await expect(trigger).toHaveFocus();
@@ -38,7 +38,7 @@
 	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]' }}
 	name="AddDropdownFocusesFirstEnabled"
 	play={async ({ canvas, userEvent }) => {
-		const trigger = await canvas.findByRole('button', { name: ATTACHMENT_TOOLTIP_TEXT });
+		const trigger = await canvas.findByRole('button', { name: attachmentTooltipText(true) });

 		trigger.focus();
 		await userEvent.keyboard('{Enter}');
diff --git a/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.stories.svelte b/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.stories.svelte
index 818b9830b..d3e302833 100644
--- a/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.stories.svelte
+++ b/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.stories.svelte
@@ -21,7 +21,7 @@
 	} from './fixtures';
 	import { defineMeta } from '@storybook/addon-svelte-csf';
 	import ChatScreenForm from '#lib/components/app/chat/ChatScreen/ChatScreenForm.svelte';
-	import { ATTACHMENT_TOOLTIP_TEXT } from '#lib/constants/index.ts';
+	import { attachmentTooltipText } from '#lib/constants/index.ts';
 	import { expect, screen } from 'storybook/test';

 	const { Story } = defineMeta({
@@ -170,7 +170,7 @@
 	args={{ class: FORM_CLASS }}
 	name="AddMenuOpen"
 	play={async ({ canvas, userEvent }) => {
-		await userEvent.click(await canvas.findByRole('button', { name: ATTACHMENT_TOOLTIP_TEXT }));
+		await userEvent.click(await canvas.findByRole('button', { name: attachmentTooltipText(true) }));
 		await screen.findByRole('menu');
 	}}
 />
diff --git a/ui/apps/chat/tests/unit/chat-only-build.test.ts b/ui/apps/chat/tests/unit/chat-only-build.test.ts
new file mode 100644
index 000000000..8176dafa7
--- /dev/null
+++ b/ui/apps/chat/tests/unit/chat-only-build.test.ts
@@ -0,0 +1,87 @@
+// A chat-only build (VITE_PUBLIC_AGENTIC=false) offers no tools, no MCP and no
+// agentic settings, and a full build offers them only for a server that has
+// them. The flag is read when the constants load, so each case loads them fresh.
+
+import { SidebarAction } from '#lib/enums/index.ts';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+async function loadConstants(agentic?: string) {
+	vi.resetModules();
+
+	if (agentic !== undefined) vi.stubEnv('VITE_PUBLIC_AGENTIC', agentic);
+
+	return import('#lib/constants/index.ts');
+}
+
+afterEach(() => {
+	vi.unstubAllEnvs();
+	vi.resetModules();
+});
+
+describe('chat-only build', () => {
+	it('is off unless the build sets the flag to false', async () => {
+		expect((await loadConstants()).AGENTIC_ENABLED).toBe(true);
+		expect((await loadConstants('true')).AGENTIC_ENABLED).toBe(true);
+		expect((await loadConstants('false')).AGENTIC_ENABLED).toBe(false);
+	});
+
+	it('gives the tools store no tools', async () => {
+		vi.resetModules();
+		vi.stubEnv('VITE_PUBLIC_AGENTIC', 'false');
+
+		const { agenticMode } = await import('#lib/stores/agentic-mode.svelte.ts');
+		const { toolsStore } = await import('#lib/stores/tools.svelte.ts');
+
+		// even for a server that offers its tools
+		agenticMode.serverHasTools = true;
+
+		expect(agenticMode.enabled).toBe(false);
+		expect(toolsStore.allTools).toEqual([]);
+		expect(toolsStore.getEnabledToolsForLLM()).toEqual([]);
+	});
+});
+
+describe('agentic mode', () => {
+	it('is on only for a server that offers its tools or its proxy', async () => {
+		vi.resetModules();
+
+		const { agenticMode } = await import('#lib/stores/agentic-mode.svelte.ts');
+		const { serverStore } = await import('#lib/stores/llama-server.svelte.ts');
+		const { toolsStore } = await import('#lib/stores/tools.svelte.ts');
+
+		expect(agenticMode.enabled).toBe(false);
+		expect(toolsStore.allTools).toEqual([]);
+
+		agenticMode.serverHasTools = true;
+
+		expect(agenticMode.enabled).toBe(true);
+		expect(toolsStore.allTools.length).toBeGreaterThan(0);
+
+		agenticMode.serverHasTools = false;
+		serverStore.props = { cors_proxy_enabled: true } as typeof serverStore.props;
+
+		expect(agenticMode.enabled).toBe(true);
+	});
+
+	it('leaves the Tools and Agentic settings and the MCP entry out when it is off', async () => {
+		const c = await loadConstants();
+		const slugs = (agentic: boolean) => c.settingsChatSections(agentic).map((s) => s.slug);
+		const keys = (agentic: boolean) =>
+			c.settingsChatSections(agentic).flatMap((s) => (s.fields ?? []).map((field) => field.key));
+		const actions = (agentic: boolean) => c.sidebarFooterItems(agentic).map((item) => item.action);
+		const { AGENTIC, TOOLS } = c.SETTINGS_SECTION_SLUGS;
+
+		expect(slugs(true)).toEqual(expect.arrayContaining([TOOLS, AGENTIC]));
+		expect(slugs(false)).not.toContain(TOOLS);
+		expect(slugs(false)).not.toContain(AGENTIC);
+		expect(slugs(false).length).toBeGreaterThan(0);
+
+		expect(keys(true)).toContain(c.SETTINGS_KEYS.SHOW_MCP);
+		expect(keys(false)).not.toContain(c.SETTINGS_KEYS.SHOW_MCP);
+
+		expect(actions(true)).toContain(SidebarAction.MCP);
+		expect(actions(false)).not.toContain(SidebarAction.MCP);
+
+		expect(c.attachmentTooltipText(false)).not.toMatch(/tools|MCP/i);
+	});
+});
diff --git a/ui/apps/chat/tsconfig.json b/ui/apps/chat/tsconfig.json
index fed5bbe9d..7c4511141 100644
--- a/ui/apps/chat/tsconfig.json
+++ b/ui/apps/chat/tsconfig.json
@@ -48,7 +48,8 @@
 			"vaul-svelte": ["./node_modules/vaul-svelte"],
 			"vaul-svelte/*": ["./node_modules/vaul-svelte/*"],
 			"@lucide/svelte/icons/*": ["./node_modules/@lucide/svelte/dist/icons/*"],
-			"@ggml-org/llama-harness": ["../../lib/harness/src/index.ts"]
+			"@ggml-org/llama-harness": ["../../lib/harness/src/index.ts"],
+			"@ggml-org/llama-harness/trace": ["../../lib/harness/src/trace/index.ts"]
 		},
 		"sourceMap": true,
 		"strict": true
diff --git a/ui/apps/chat/vite.config.ts b/ui/apps/chat/vite.config.ts
index 68493dad9..016234de8 100644
--- a/ui/apps/chat/vite.config.ts
+++ b/ui/apps/chat/vite.config.ts
@@ -19,6 +19,12 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
 const LLAMA_VOICE_SOURCE = resolve(__dirname, '../../lib/voice/src');
 // the harness has no build step in the repo: the app compiles it from source
 const LLAMA_HARNESS_ENTRY = resolve(__dirname, '../../lib/harness/src/index.ts');
+const LLAMA_HARNESS_TRACE_ENTRY = resolve(__dirname, '../../lib/harness/src/trace/index.ts');
+// what a chat-only build (VITE_PUBLIC_AGENTIC=false) gets in place of the harness: its trace phrasing, no loop
+const LLAMA_HARNESS_CHAT_ONLY_ENTRY = resolve(
+	__dirname,
+	'src/lib/stores/agentic/harness-chat-only.ts'
+);
 // eslint-disable-next-line @typescript-eslint/no-explicit-any
 const browserBaseConfig: any = {
 	enabled: true,
@@ -87,7 +93,14 @@ export default defineConfig(({ mode }) => {
 					replacement: resolve(LLAMA_VOICE_SOURCE, 'svelte/index.ts')
 				},
 				{ find: /^@ggml-org\/llama-voice$/, replacement: resolve(LLAMA_VOICE_SOURCE, 'index.ts') },
-				{ find: /^@ggml-org\/llama-harness$/, replacement: LLAMA_HARNESS_ENTRY },
+				{ find: /^@ggml-org\/llama-harness\/trace$/, replacement: LLAMA_HARNESS_TRACE_ENTRY },
+				{
+					find: /^@ggml-org\/llama-harness$/,
+					replacement:
+						env.VITE_PUBLIC_AGENTIC === 'false'
+							? LLAMA_HARNESS_CHAT_ONLY_ENTRY
+							: LLAMA_HARNESS_ENTRY
+				},
 				{ find: 'katex-fonts', replacement: resolve('node_modules/katex/dist/fonts') }
 			]
 		},
diff --git a/ui/apps/chat/vitest-setup-client.ts b/ui/apps/chat/vitest-setup-client.ts
index 06d275c25..696bbf3dc 100644
--- a/ui/apps/chat/vitest-setup-client.ts
+++ b/ui/apps/chat/vitest-setup-client.ts
@@ -1,6 +1,7 @@
 /// <reference types="@vitest/browser/matchers" />
 /// <reference types="@vitest/browser/providers/playwright" />

+import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts';
 import { beforeEach, vi } from 'vitest';

 // Mock fetch for API calls during client tests.
@@ -13,6 +14,9 @@ import { beforeEach, vi } from 'vitest';
 const originalFetch = globalThis.fetch.bind(globalThis);

 beforeEach(() => {
+	// the tests run as against a llama-server started with --agent
+	agenticMode.serverHasTools = true;
+
 	vi.spyOn(globalThis, 'fetch').mockImplementation(
 		async (input: RequestInfo | URL, init?: RequestInit) => {
 			const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
diff --git a/ui/lib/harness/package.json b/ui/lib/harness/package.json
index b93deffb2..a90780737 100644
--- a/ui/lib/harness/package.json
+++ b/ui/lib/harness/package.json
@@ -19,6 +19,10 @@
     ".": {
       "types": "./dist/index.d.ts",
       "default": "./dist/index.js"
+    },
+    "./trace": {
+      "types": "./dist/trace/index.d.ts",
+      "default": "./dist/trace/index.js"
     }
   },
   "scripts": {