mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-17 08:19:38 +02:00
webui: stop re-probing disabled /tools endpoint on every message (#28646)
When /tools returns 403 (server started without tools), the web UI refetched the tool list before every chat message, since the guard treated an empty tool list as "not yet fetched". Each retry returned 403 and could trip fail2ban. Skip the refetch once the store flags the endpoint as disabled, and detect that state via the response status code instead of string- matching the error message. The tools panel keeps probing on open so the UI recovers once the server is restarted with tools enabled. Fixes #28299
This commit is contained in:
@@ -47,7 +47,7 @@ export function useToolsPanel(): UseToolsPanelReturn {
|
||||
|
||||
if (toolsStore.toolGroups.length > 0) return null;
|
||||
|
||||
// Tools endpoint is unreachable (404) — server started without --tools
|
||||
// Tools endpoint unreachable (403) — server started without tools
|
||||
if (toolsStore.isToolsEndpointUnreachable) {
|
||||
return `To enable Server Tools you need to run llama-server with ${CLI_FLAGS.TOOLS} all or ${CLI_FLAGS.TOOLS} <name> flag. To see MCP Tools you need to add / enable MCP Server(s).`;
|
||||
}
|
||||
|
||||
@@ -315,8 +315,14 @@ class AgenticStore {
|
||||
// Clear any pending permissions/continue requests for this conversation when starting a new flow
|
||||
this.gates.clear(conversationId);
|
||||
|
||||
// Ensure server tools are fetched before checking if agentic is enabled
|
||||
if (toolsStore.serverTools.length === 0 && !toolsStore.loading) {
|
||||
// Ensure server tools are fetched before checking if agentic is enabled.
|
||||
// A disabled /tools endpoint stays disabled for the life of the server,
|
||||
// so the tools panel is the only place that probes it again.
|
||||
if (
|
||||
toolsStore.serverTools.length === 0 &&
|
||||
!toolsStore.loading &&
|
||||
!toolsStore.isToolsEndpointUnreachable
|
||||
) {
|
||||
await toolsStore.fetchServerTools();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import { mcpStore } from '$lib/stores/mcp/index.svelte';
|
||||
import { modelsStore } from '$lib/stores/models/index.svelte';
|
||||
import { settingsStore } from '$lib/stores/settings/index.svelte';
|
||||
import type { OpenAIToolDefinition, ToolEntry, ToolGroup } from '$lib/types';
|
||||
import { buildSandboxToolDefinition } from '$lib/utils';
|
||||
import { ApiError, buildSandboxToolDefinition } from '$lib/utils';
|
||||
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
||||
|
||||
/** Stable selection identity for a tool, shared by the disabled set and the permission store */
|
||||
@@ -246,13 +246,10 @@ class ToolsStore {
|
||||
toolInfos.filter((info) => info.uses_cwd).map((info) => info.tool)
|
||||
);
|
||||
} catch (err) {
|
||||
const errorMessage = err instanceof Error ? err.message : String(err);
|
||||
|
||||
this._error = errorMessage;
|
||||
this._error = err instanceof Error ? err.message : String(err);
|
||||
|
||||
// 403 from /tools means the server was started without --tools
|
||||
// TODO: check status code instead of relying on message
|
||||
if (errorMessage.includes('this feature is disabled')) {
|
||||
if (err instanceof ApiError && err.status === 403) {
|
||||
this._toolsEndpointUnreachable = true;
|
||||
console.info('[ToolsStore] Server tools are disabled on the server');
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user