@@ -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
1616nockBack . fixtures = path . join ( __dirname , "fixtures" )
1717nockBack . 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} )
0 commit comments