Skip to content

Commit 700fe42

Browse files
authored
Look for a tag in the Roo provider to default the model to native tool calling (#9735)
1 parent d2b274a commit 700fe42

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed

src/api/providers/fetchers/__tests__/roo.spec.ts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,4 +543,106 @@ describe("getRooModels", () => {
543543

544544
expect(models["test/model-no-temp"].defaultTemperature).toBeUndefined()
545545
})
546+
547+
it("should set defaultToolProtocol to native when default-native-tools tag is present", async () => {
548+
const mockResponse = {
549+
object: "list",
550+
data: [
551+
{
552+
id: "test/native-tools-model",
553+
object: "model",
554+
created: 1234567890,
555+
owned_by: "test",
556+
name: "Native Tools Model",
557+
description: "Model with native tool calling default",
558+
context_window: 128000,
559+
max_tokens: 8192,
560+
type: "language",
561+
tags: ["tool-use", "default-native-tools"],
562+
pricing: {
563+
input: "0.0001",
564+
output: "0.0002",
565+
},
566+
},
567+
],
568+
}
569+
570+
mockFetch.mockResolvedValueOnce({
571+
ok: true,
572+
json: async () => mockResponse,
573+
})
574+
575+
const models = await getRooModels(baseUrl, apiKey)
576+
577+
expect(models["test/native-tools-model"].supportsNativeTools).toBe(true)
578+
expect(models["test/native-tools-model"].defaultToolProtocol).toBe("native")
579+
})
580+
581+
it("should imply supportsNativeTools when default-native-tools tag is present without tool-use tag", async () => {
582+
const mockResponse = {
583+
object: "list",
584+
data: [
585+
{
586+
id: "test/implicit-native-tools",
587+
object: "model",
588+
created: 1234567890,
589+
owned_by: "test",
590+
name: "Implicit Native Tools Model",
591+
description: "Model with default-native-tools but no tool-use tag",
592+
context_window: 128000,
593+
max_tokens: 8192,
594+
type: "language",
595+
tags: ["default-native-tools"], // Only default-native-tools, no tool-use
596+
pricing: {
597+
input: "0.0001",
598+
output: "0.0002",
599+
},
600+
},
601+
],
602+
}
603+
604+
mockFetch.mockResolvedValueOnce({
605+
ok: true,
606+
json: async () => mockResponse,
607+
})
608+
609+
const models = await getRooModels(baseUrl, apiKey)
610+
611+
expect(models["test/implicit-native-tools"].supportsNativeTools).toBe(true)
612+
expect(models["test/implicit-native-tools"].defaultToolProtocol).toBe("native")
613+
})
614+
615+
it("should not set defaultToolProtocol when default-native-tools tag is not present", async () => {
616+
const mockResponse = {
617+
object: "list",
618+
data: [
619+
{
620+
id: "test/non-native-model",
621+
object: "model",
622+
created: 1234567890,
623+
owned_by: "test",
624+
name: "Non-Native Tools Model",
625+
description: "Model without native tool calling default",
626+
context_window: 128000,
627+
max_tokens: 8192,
628+
type: "language",
629+
tags: ["tool-use"],
630+
pricing: {
631+
input: "0.0001",
632+
output: "0.0002",
633+
},
634+
},
635+
],
636+
}
637+
638+
mockFetch.mockResolvedValueOnce({
639+
ok: true,
640+
json: async () => mockResponse,
641+
})
642+
643+
const models = await getRooModels(baseUrl, apiKey)
644+
645+
expect(models["test/non-native-model"].supportsNativeTools).toBe(true)
646+
expect(models["test/non-native-model"].defaultToolProtocol).toBeUndefined()
647+
})
546648
})

src/api/providers/fetchers/roo.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
107107
// Determine if the model requires reasoning effort based on tags
108108
const requiredReasoningEffort = tags.includes("reasoning-required")
109109

110+
// Determine if native tool calling should be the default protocol for this model
111+
const hasDefaultNativeTools = tags.includes("default-native-tools")
112+
const defaultToolProtocol = hasDefaultNativeTools ? ("native" as const) : undefined
113+
110114
// Determine if the model supports native tool calling based on tags
111-
const supportsNativeTools = tags.includes("tool-use")
115+
// default-native-tools implies tool-use support
116+
const supportsNativeTools = tags.includes("tool-use") || hasDefaultNativeTools
112117

113118
// Parse pricing (API returns strings, convert to numbers)
114119
const inputPrice = parseApiPrice(pricing.input)
@@ -133,6 +138,7 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
133138
deprecated: model.deprecated || false,
134139
isFree: tags.includes("free"),
135140
defaultTemperature: model.default_temperature,
141+
defaultToolProtocol,
136142
}
137143

138144
// Apply model-specific defaults (e.g., defaultToolProtocol)

0 commit comments

Comments
 (0)