Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions src/api/providers/fetchers/__tests__/roo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
8 changes: 7 additions & 1 deletion src/api/providers/fetchers/roo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading