From 3cb7bee4d7b67110ad0be6162fe297df24417728 Mon Sep 17 00:00:00 2001 From: armorbreak001 Date: Wed, 15 Apr 2026 08:39:07 +0800 Subject: [PATCH] fix: clear incompatible tools when switching models When switching from a model with tools to one without those tools, the previously selected tools remained active. This happened because the settings.tools fallback did not check compatibility with the current model. Now when a model doesn't define toolIds, the global settings tools are only applied if they are compatible with the current model's filters or toolIds. This prevents tools from a previous model from leaking into a model that doesn't support them. Fixes #14157 --- src/lib/components/chat/Chat.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index a3fd62d3bd..df2eeb2ff9 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -338,7 +338,12 @@ selectedToolIds = authed; pendingOAuthTools = unauthed; } else if ($settings?.tools) { - selectedToolIds = $settings.tools; + // Only apply global tool settings for tools compatible with the current model + const modelFilterIds = model?.filters?.map((f) => f.id) ?? []; + const modelToolIds = model?.info?.meta?.toolIds ?? []; + selectedToolIds = $settings.tools.filter( + (id) => modelToolIds.includes(id) || modelFilterIds.includes(id) + ); } else { selectedToolIds = selectedToolIds.filter((id) => !id.startsWith('direct_server:')); }