diff --git a/src/api/providers/fetchers/__tests__/openrouter.spec.ts b/src/api/providers/fetchers/__tests__/openrouter.spec.ts index f0ebead30f..e1f8d64acd 100644 --- a/src/api/providers/fetchers/__tests__/openrouter.spec.ts +++ b/src/api/providers/fetchers/__tests__/openrouter.spec.ts @@ -11,7 +11,7 @@ import { OPEN_ROUTER_REQUIRED_REASONING_BUDGET_MODELS, } from "@roo-code/types" -import { getOpenRouterModelEndpoints, getOpenRouterModels } from "../openrouter" +import { getOpenRouterModelEndpoints, getOpenRouterModels, parseOpenRouterModel } from "../openrouter" nockBack.fixtures = path.join(__dirname, "fixtures") nockBack.setMode("lockdown") @@ -251,4 +251,52 @@ describe("OpenRouter API", () => { nockDone() }) }) + + describe("parseOpenRouterModel", () => { + it("sets horizon-alpha model to 32k max tokens", () => { + const mockModel = { + name: "Horizon Alpha", + description: "Test model", + context_length: 128000, + max_completion_tokens: 128000, + pricing: { + prompt: "0.000003", + completion: "0.000015", + }, + } + + const result = parseOpenRouterModel({ + id: "openrouter/horizon-alpha", + model: mockModel, + modality: "text", + maxTokens: 128000, + }) + + expect(result.maxTokens).toBe(32768) + expect(result.contextWindow).toBe(128000) + }) + + it("does not override max tokens for other models", () => { + const mockModel = { + name: "Other Model", + description: "Test model", + context_length: 128000, + max_completion_tokens: 64000, + pricing: { + prompt: "0.000003", + completion: "0.000015", + }, + } + + const result = parseOpenRouterModel({ + id: "openrouter/other-model", + model: mockModel, + modality: "text", + maxTokens: 64000, + }) + + expect(result.maxTokens).toBe(64000) + expect(result.contextWindow).toBe(128000) + }) + }) }) diff --git a/src/api/providers/fetchers/openrouter.ts b/src/api/providers/fetchers/openrouter.ts index 027f8c54fb..34e2ec595f 100644 --- a/src/api/providers/fetchers/openrouter.ts +++ b/src/api/providers/fetchers/openrouter.ts @@ -232,5 +232,10 @@ export const parseOpenRouterModel = ({ modelInfo.maxTokens = anthropicModels["claude-3-7-sonnet-20250219:thinking"].maxTokens } + // Set horizon-alpha model to 32k max tokens + if (id === "openrouter/horizon-alpha") { + modelInfo.maxTokens = 32768 + } + return modelInfo }