Look for a tag in the Roo provider to default the model to native tool calling (#9735)

This commit is contained in:
Matt Rubens 2025-12-02 00:12:57 -05:00 committed by GitHub
parent d2b274a9af
commit 700fe42669
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 109 additions and 1 deletions

View file

@ -543,4 +543,106 @@ describe("getRooModels", () => {
expect(models["test/model-no-temp"].defaultTemperature).toBeUndefined()
})
it("should set defaultToolProtocol to native when default-native-tools tag is present", async () => {
const mockResponse = {
object: "list",
data: [
{
id: "test/native-tools-model",
object: "model",
created: 1234567890,
owned_by: "test",
name: "Native Tools Model",
description: "Model with native tool calling default",
context_window: 128000,
max_tokens: 8192,
type: "language",
tags: ["tool-use", "default-native-tools"],
pricing: {
input: "0.0001",
output: "0.0002",
},
},
],
}
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => mockResponse,
})
const models = await getRooModels(baseUrl, apiKey)
expect(models["test/native-tools-model"].supportsNativeTools).toBe(true)
expect(models["test/native-tools-model"].defaultToolProtocol).toBe("native")
})
it("should imply supportsNativeTools when default-native-tools tag is present without tool-use tag", async () => {
const mockResponse = {
object: "list",
data: [
{
id: "test/implicit-native-tools",
object: "model",
created: 1234567890,
owned_by: "test",
name: "Implicit Native Tools Model",
description: "Model with default-native-tools but no tool-use tag",
context_window: 128000,
max_tokens: 8192,
type: "language",
tags: ["default-native-tools"], // Only default-native-tools, no tool-use
pricing: {
input: "0.0001",
output: "0.0002",
},
},
],
}
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => mockResponse,
})
const models = await getRooModels(baseUrl, apiKey)
expect(models["test/implicit-native-tools"].supportsNativeTools).toBe(true)
expect(models["test/implicit-native-tools"].defaultToolProtocol).toBe("native")
})
it("should not set defaultToolProtocol when default-native-tools tag is not present", async () => {
const mockResponse = {
object: "list",
data: [
{
id: "test/non-native-model",
object: "model",
created: 1234567890,
owned_by: "test",
name: "Non-Native Tools Model",
description: "Model without native tool calling default",
context_window: 128000,
max_tokens: 8192,
type: "language",
tags: ["tool-use"],
pricing: {
input: "0.0001",
output: "0.0002",
},
},
],
}
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => mockResponse,
})
const models = await getRooModels(baseUrl, apiKey)
expect(models["test/non-native-model"].supportsNativeTools).toBe(true)
expect(models["test/non-native-model"].defaultToolProtocol).toBeUndefined()
})
})

View file

@ -107,8 +107,13 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
// Determine if the model requires reasoning effort based on tags
const requiredReasoningEffort = tags.includes("reasoning-required")
// Determine if native tool calling should be the default protocol for this model
const hasDefaultNativeTools = tags.includes("default-native-tools")
const defaultToolProtocol = hasDefaultNativeTools ? ("native" as const) : undefined
// Determine if the model supports native tool calling based on tags
const supportsNativeTools = tags.includes("tool-use")
// default-native-tools implies tool-use support
const supportsNativeTools = tags.includes("tool-use") || hasDefaultNativeTools
// Parse pricing (API returns strings, convert to numbers)
const inputPrice = parseApiPrice(pricing.input)
@ -133,6 +138,7 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
deprecated: model.deprecated || false,
isFree: tags.includes("free"),
defaultTemperature: model.default_temperature,
defaultToolProtocol,
}
// Apply model-specific defaults (e.g., defaultToolProtocol)