Skip to content

Commit f173c9c

Browse files
authored
feat: set native tools as default for minimax-m2 and claude-haiku-4.5 (#9586)
1 parent 37d2f59 commit f173c9c

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ vitest.mock("../../providers/fetchers/modelCache", () => ({
102102
inputPrice: 0,
103103
outputPrice: 0,
104104
},
105+
"minimax/minimax-m2": {
106+
maxTokens: 32_768,
107+
contextWindow: 1_000_000,
108+
supportsImages: false,
109+
supportsPromptCache: true,
110+
supportsNativeTools: true,
111+
inputPrice: 0.15,
112+
outputPrice: 0.6,
113+
},
114+
"anthropic/claude-haiku-4.5": {
115+
maxTokens: 8_192,
116+
contextWindow: 200_000,
117+
supportsImages: true,
118+
supportsPromptCache: true,
119+
supportsNativeTools: true,
120+
inputPrice: 0.8,
121+
outputPrice: 4,
122+
},
105123
}
106124
}
107125
return {}
@@ -402,6 +420,41 @@ describe("RooHandler", () => {
402420
expect(modelInfo.info.contextWindow).toBeDefined()
403421
}
404422
})
423+
424+
it("should apply defaultToolProtocol: native for minimax/minimax-m2", () => {
425+
const handlerWithMinimax = new RooHandler({
426+
apiModelId: "minimax/minimax-m2",
427+
})
428+
const modelInfo = handlerWithMinimax.getModel()
429+
expect(modelInfo.id).toBe("minimax/minimax-m2")
430+
expect((modelInfo.info as any).defaultToolProtocol).toBe("native")
431+
// Verify cached model info is preserved
432+
expect(modelInfo.info.maxTokens).toBe(32_768)
433+
expect(modelInfo.info.contextWindow).toBe(1_000_000)
434+
})
435+
436+
it("should apply defaultToolProtocol: native for anthropic/claude-haiku-4.5", () => {
437+
const handlerWithHaiku = new RooHandler({
438+
apiModelId: "anthropic/claude-haiku-4.5",
439+
})
440+
const modelInfo = handlerWithHaiku.getModel()
441+
expect(modelInfo.id).toBe("anthropic/claude-haiku-4.5")
442+
expect((modelInfo.info as any).defaultToolProtocol).toBe("native")
443+
// Verify cached model info is preserved
444+
expect(modelInfo.info.maxTokens).toBe(8_192)
445+
expect(modelInfo.info.contextWindow).toBe(200_000)
446+
})
447+
448+
it("should not override existing properties when applying MODEL_DEFAULTS", () => {
449+
const handlerWithMinimax = new RooHandler({
450+
apiModelId: "minimax/minimax-m2",
451+
})
452+
const modelInfo = handlerWithMinimax.getModel()
453+
// The defaults should be merged, but not overwrite existing cached values
454+
expect(modelInfo.info.supportsNativeTools).toBe(true)
455+
expect(modelInfo.info.inputPrice).toBe(0.15)
456+
expect(modelInfo.info.outputPrice).toBe(0.6)
457+
})
405458
})
406459

407460
describe("temperature and model configuration", () => {

src/api/providers/roo.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ import { handleOpenAIError } from "./utils/openai-error-handler"
1818
import { generateImageWithProvider, generateImageWithImagesApi, ImageGenerationResult } from "./utils/image-generation"
1919
import { t } from "../../i18n"
2020

21+
import type { ModelInfo } from "@roo-code/types"
22+
23+
// Model-specific defaults that should be applied even when models come from API cache
24+
const MODEL_DEFAULTS: Record<string, Partial<ModelInfo>> = {
25+
"minimax/minimax-m2": {
26+
defaultToolProtocol: "native",
27+
},
28+
"anthropic/claude-haiku-4.5": {
29+
defaultToolProtocol: "native",
30+
},
31+
}
32+
2133
// Extend OpenAI's CompletionUsage to include Roo specific fields
2234
interface RooUsage extends OpenAI.CompletionUsage {
2335
cache_creation_input_tokens?: number
@@ -245,8 +257,13 @@ export class RooHandler extends BaseOpenAiCompatibleProvider<string> {
245257
const models = getModelsFromCache("roo") || {}
246258
const modelInfo = models[modelId]
247259

260+
// Get model-specific defaults if they exist
261+
const modelDefaults = MODEL_DEFAULTS[modelId]
262+
248263
if (modelInfo) {
249-
return { id: modelId, info: modelInfo }
264+
// Merge model-specific defaults with cached model info
265+
const mergedInfo = modelDefaults ? { ...modelInfo, ...modelDefaults } : modelInfo
266+
return { id: modelId, info: mergedInfo }
250267
}
251268

252269
// Return the requested model ID even if not found, with fallback info.

0 commit comments

Comments
 (0)