@@ -5366,6 +5366,49 @@ describe("Codex catalog routed normalization", () => {
53665366 expect ( routed ?. context_window ) . toBe ( 64_000 ) ;
53675367 } ) ;
53685368
5369+ test ( "GitHub Copilot capabilities preserve the live context window (#3156)" , async ( ) => {
5370+ globalThis . fetch = ( async ( ) => new Response ( JSON . stringify ( {
5371+ data : [ {
5372+ id : "copilot-wide-model" ,
5373+ capabilities : {
5374+ limits : { max_context_window_tokens : 1_000_000 } ,
5375+ } ,
5376+ } , {
5377+ id : "copilot-existing-metadata" ,
5378+ metadata : { limits : { max_context_length : 256_000 } } ,
5379+ capabilities : {
5380+ limits : { max_context_window_tokens : 1_000_000 } ,
5381+ } ,
5382+ } , {
5383+ id : "copilot-invalid-window" ,
5384+ capabilities : {
5385+ limits : { max_context_window_tokens : - 1 } ,
5386+ } ,
5387+ } ] ,
5388+ } ) ) ) as typeof fetch ;
5389+
5390+ const models = await gatherRoutedModels ( {
5391+ port : 10100 ,
5392+ defaultProvider : "github-copilot" ,
5393+ providers : {
5394+ "github-copilot" : {
5395+ adapter : "openai-chat" ,
5396+ baseUrl : "https://api.githubcopilot.com" ,
5397+ apiKey : "sk-test" ,
5398+ } ,
5399+ } ,
5400+ } ) ;
5401+ const routed = buildCatalogEntries ( nativeTemplate ( ) , [ ] , models )
5402+ . find ( entry => entry . slug === "github-copilot/copilot-wide-model" ) ;
5403+
5404+ expect ( models . find ( model => model . id === "copilot-wide-model" ) ?. contextWindow ) . toBe ( 1_000_000 ) ;
5405+ expect ( routed ?. context_window ) . toBe ( 1_000_000 ) ;
5406+ expect ( routed ?. max_context_window ) . toBe ( 1_000_000 ) ;
5407+ expect ( routed ?. auto_compact_token_limit ) . toBe ( 900_000 ) ;
5408+ expect ( models . find ( model => model . id === "copilot-existing-metadata" ) ?. contextWindow ) . toBe ( 256_000 ) ;
5409+ expect ( models . find ( model => model . id === "copilot-invalid-window" ) ?. contextWindow ) . toBeUndefined ( ) ;
5410+ } ) ;
5411+
53695412 test ( "liveModels false preserves configured catalog metadata without live fetch" , async ( ) => {
53705413 let fetchCalls = 0 ;
53715414 globalThis . fetch = ( ( ) => {
0 commit comments