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
33 changes: 0 additions & 33 deletions packages/types/src/providers/roo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { z } from "zod"

import type { ModelInfo } from "../model.js"
import { TOOL_PROTOCOL } from "../tool.js"

/**
* Roo Code Cloud is a dynamic provider - models are loaded from the /v1/models API endpoint.
Expand All @@ -15,38 +14,6 @@ export const rooDefaultModelId = "xai/grok-code-fast-1"
*/
export const rooModels = {} as const satisfies Record<string, ModelInfo>

/**
* Model-specific defaults for Roo provider models.
* These defaults are merged with dynamically fetched model data.
*
* Use this to configure model-specific settings like defaultToolProtocol.
*
* Example usage:
* ```typescript
* export const rooModelDefaults: Record<string, Partial<ModelInfo>> = {
* "anthropic/claude-3-5-sonnet-20241022": {
* defaultToolProtocol: "xml",
* },
* "openai/gpt-4o": {
* defaultToolProtocol: "native",
* },
* "xai/grok-code-fast-1": {
* defaultToolProtocol: "native",
* },
* }
* ```
*/
export const rooModelDefaults: Record<string, Partial<ModelInfo>> = {
// Add model-specific defaults below.
// You can configure defaultToolProtocol and other ModelInfo fields for specific model IDs.
"anthropic/claude-haiku-4.5": {
defaultToolProtocol: TOOL_PROTOCOL.NATIVE,
},
"minimax/minimax-m2:free": {
defaultToolProtocol: TOOL_PROTOCOL.NATIVE,
},
}

/**
* Roo Code Cloud API response schemas
*/
Expand Down
7 changes: 2 additions & 5 deletions src/api/providers/fetchers/roo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RooModelsResponseSchema, rooModelDefaults } from "@roo-code/types"
import { RooModelsResponseSchema } from "@roo-code/types"

import type { ModelRecord } from "../../../shared/api"
import { parseApiPrice } from "../../../shared/cost"
Expand Down Expand Up @@ -119,10 +119,7 @@ export async function getRooModels(baseUrl: string, apiKey?: string): Promise<Mo
isFree: tags.includes("free"),
}

// Merge with model-specific defaults if they exist
// Defaults take precedence over dynamically fetched data for specified fields
const modelDefaults = rooModelDefaults[modelId]
models[modelId] = modelDefaults ? { ...baseModelInfo, ...modelDefaults } : baseModelInfo
models[modelId] = baseModelInfo
}

return models
Expand Down
9 changes: 2 additions & 7 deletions src/api/providers/roo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Anthropic } from "@anthropic-ai/sdk"
import OpenAI from "openai"

import { rooDefaultModelId, rooModelDefaults, getApiProtocol } from "@roo-code/types"
import { rooDefaultModelId, getApiProtocol } from "@roo-code/types"
import { CloudService } from "@roo-code/cloud"

import type { ApiHandlerOptions, ModelRecord } from "../../shared/api"
Expand Down Expand Up @@ -274,8 +274,7 @@ export class RooHandler extends BaseOpenAiCompatibleProvider<string> {
}

// Return the requested model ID even if not found, with fallback info.
// Check if there are model-specific defaults configured
const baseModelInfo = {
const fallbackInfo = {
maxTokens: 16_384,
contextWindow: 262_144,
supportsImages: false,
Expand All @@ -287,10 +286,6 @@ export class RooHandler extends BaseOpenAiCompatibleProvider<string> {
isFree: false,
}

// Merge with model-specific defaults if they exist
const modelDefaults = rooModelDefaults[modelId]
const fallbackInfo = modelDefaults ? { ...baseModelInfo, ...modelDefaults } : baseModelInfo

return {
id: modelId,
info: fallbackInfo,
Expand Down
Loading