fix: built-in tools show while the model's matching capability is off (#32965)

* fix: built-in tools show while the model's matching capability is off

The Files built-in tool showed in the model editor although a model only gets it while File Upload is on and File Context is off, and File Context is on by default. The Memory, Web Search, Image Generation and Code Interpreter tools also showed while the same capability was off on that model. These tools now appear and disappear as the model's capabilities are switched, and the saved tool choices are kept for when the capability is turned back on.

Refs #32830

* refac: filter built-in tools by their capability directly

Same behaviour, with the per-tool capability list folded into the filter.

* fix: treat unset file capabilities as on when showing the Files tool

Matches how the server decides whether a model gets the Files tool.
This commit is contained in:
Classic298 2026-10-25 00:35:35 +02:00 • committed by GitHub
parent d2e88ba37a
commit 758e4f6cc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -79,9 +79,15 @@
}
};
$: allTools = Object.keys(toolLabels ?? {}) as Array<keyof typeof toolLabels>;
// with File Context on, attached files go into the prompt instead
$: allTools = (Object.keys(toolLabels ?? {}) as Array<keyof typeof toolLabels>).filter((key) =>
key === 'files'
? (capabilities.file_upload ?? true) && !(capabilities.file_context ?? true)
: (capabilities[key] ?? true)
);
export let builtinTools: Record<string, boolean> = {};
export let capabilities: Record<string, boolean> = {};
export let disabled = false;
$: enabledTools = allTools.filter((key) => builtinTools[key] !== false);

View file

@ -162,6 +162,6 @@
{/if}
{#if capabilities.builtin_tools}
<BuiltinTools bind:builtinTools {disabled} />
<BuiltinTools bind:builtinTools {capabilities} {disabled} />
{/if}
</div>