/
outbreak
/
kilocode
Обзор
Документация
Войти
/
outbreak
/
kilocode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/utils/resolveToolProtocol.ts
36 строк
1 KB
Christiaan Arnoldus
Tool protocol cleanup
11 дек 2025, 17:18
11 дек 2025, 17:18
4357fdb
Код
Авторство
О чём код?
import { ToolProtocol, TOOL_PROTOCOL } from "@roo-code/types" import type { ProviderSettings, ModelInfo } from "@roo-code/types" /** * Resolve the effective tool protocol based on the precedence hierarchy: * * 1. User Preference - Per-Profile (explicit profile setting) * 2. Model Default (defaultToolProtocol in ModelInfo) * 3. XML Fallback (final fallback) * * Then check support: if protocol is "native" but model doesn't support it, use XML. * * @param providerSettings - The provider settings for the current profile * @param modelInfo - Optional model information containing capabilities * @returns The resolved tool protocol (either "xml" or "native") */ export function resolveToolProtocol(providerSettings: ProviderSettings, modelInfo?: ModelInfo): ToolProtocol { // If model doesn't support native tools, return XML immediately // Treat undefined as unsupported (only allow native when explicitly true) if (modelInfo?.supportsNativeTools !== true) { return TOOL_PROTOCOL.XML } // 1. User Preference - Per-Profile (explicit profile setting, highest priority) if (providerSettings.toolProtocol) { return providerSettings.toolProtocol } // 2. Model Default - model's preferred protocol if (modelInfo?.defaultToolProtocol) { return modelInfo.defaultToolProtocol } // 3. XML Fallback return TOOL_PROTOCOL.XML }