Skip to content

Commit c47e857

Browse files
feat: set horizon-alpha model max tokens to 32k for OpenRouter (#6470)
Co-authored-by: Roo Code <[email protected]>
1 parent 01f5320 commit c47e857

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
OPEN_ROUTER_REQUIRED_REASONING_BUDGET_MODELS,
1212
} from "@roo-code/types"
1313

14-
import { getOpenRouterModelEndpoints, getOpenRouterModels } from "../openrouter"
14+
import { getOpenRouterModelEndpoints, getOpenRouterModels, parseOpenRouterModel } from "../openrouter"
1515

1616
nockBack.fixtures = path.join(__dirname, "fixtures")
1717
nockBack.setMode("lockdown")
@@ -251,4 +251,52 @@ describe("OpenRouter API", () => {
251251
nockDone()
252252
})
253253
})
254+
255+
describe("parseOpenRouterModel", () => {
256+
it("sets horizon-alpha model to 32k max tokens", () => {
257+
const mockModel = {
258+
name: "Horizon Alpha",
259+
description: "Test model",
260+
context_length: 128000,
261+
max_completion_tokens: 128000,
262+
pricing: {
263+
prompt: "0.000003",
264+
completion: "0.000015",
265+
},
266+
}
267+
268+
const result = parseOpenRouterModel({
269+
id: "openrouter/horizon-alpha",
270+
model: mockModel,
271+
modality: "text",
272+
maxTokens: 128000,
273+
})
274+
275+
expect(result.maxTokens).toBe(32768)
276+
expect(result.contextWindow).toBe(128000)
277+
})
278+
279+
it("does not override max tokens for other models", () => {
280+
const mockModel = {
281+
name: "Other Model",
282+
description: "Test model",
283+
context_length: 128000,
284+
max_completion_tokens: 64000,
285+
pricing: {
286+
prompt: "0.000003",
287+
completion: "0.000015",
288+
},
289+
}
290+
291+
const result = parseOpenRouterModel({
292+
id: "openrouter/other-model",
293+
model: mockModel,
294+
modality: "text",
295+
maxTokens: 64000,
296+
})
297+
298+
expect(result.maxTokens).toBe(64000)
299+
expect(result.contextWindow).toBe(128000)
300+
})
301+
})
254302
})

src/api/providers/fetchers/openrouter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,10 @@ export const parseOpenRouterModel = ({
232232
modelInfo.maxTokens = anthropicModels["claude-3-7-sonnet-20250219:thinking"].maxTokens
233233
}
234234

235+
// Set horizon-alpha model to 32k max tokens
236+
if (id === "openrouter/horizon-alpha") {
237+
modelInfo.maxTokens = 32768
238+
}
239+
235240
return modelInfo
236241
}

0 commit comments

Comments
 (0)