diff --git a/src/api/providers/__tests__/roo.spec.ts b/src/api/providers/__tests__/roo.spec.ts index cd1ab3330104..dd4eb32fc1d3 100644 --- a/src/api/providers/__tests__/roo.spec.ts +++ b/src/api/providers/__tests__/roo.spec.ts @@ -368,6 +368,33 @@ describe("RooHandler", () => { expect(modelInfo.info.contextWindow).toBeDefined() } }) + + it("should migrate deprecated code-supernova model ID to code-supernova-1-million", () => { + const handlerWithDeprecatedModel = new RooHandler({ + apiModelId: "roo/code-supernova", + }) + const modelInfo = handlerWithDeprecatedModel.getModel() + // Should return the migrated model ID + expect(modelInfo.id).toBe("roo/code-supernova-1-million") + expect(modelInfo.info).toBeDefined() + }) + + it("should not migrate non-deprecated model IDs", () => { + const testCases = [ + "roo/code-supernova-1-million", // Already migrated + "xai/grok-code-fast-1", // Different model + "roo/sonic", // Different model + "unknown-model", // Unknown model + ] + + for (const modelId of testCases) { + const handlerWithModel = new RooHandler({ apiModelId: modelId }) + const modelInfo = handlerWithModel.getModel() + // Should return the same model ID without migration + expect(modelInfo.id).toBe(modelId) + expect(modelInfo.info).toBeDefined() + } + }) }) describe("temperature and model configuration", () => { diff --git a/src/api/providers/roo.ts b/src/api/providers/roo.ts index 3bd1bb65dc36..68a84edea3b2 100644 --- a/src/api/providers/roo.ts +++ b/src/api/providers/roo.ts @@ -210,7 +210,17 @@ export class RooHandler extends BaseOpenAiCompatibleProvider { } override getModel() { - const modelId = this.options.apiModelId || rooDefaultModelId + let modelId = this.options.apiModelId || rooDefaultModelId + + // Migrate deprecated model IDs to their new versions + const modelMigrations: Record = { + "roo/code-supernova": "roo/code-supernova-1-million", + } + + // Apply migration if needed + if (modelMigrations[modelId]) { + modelId = modelMigrations[modelId] + } // Get models from shared cache const models = getModelsFromCache("roo") || {}