@@ -64,6 +64,44 @@ describe("huggingface models", () => {
6464 expect ( models ) . toEqual ( [ { ...bundledModel , contextWindow : 64000 } ] ) ;
6565 } ) ;
6666
67+ it ( "limits discovered models to every available route regardless of provider order" , async ( ) => {
68+ const bundledModel = HUGGINGFACE_MODEL_CATALOG [ 0 ] ! ;
69+ vi . stubGlobal (
70+ "fetch" ,
71+ vi . fn ( async ( ) =>
72+ Response . json ( {
73+ data : [
74+ {
75+ id : "Qwen/Qwen3.8-2.4T-A95B" ,
76+ providers : [ { context_length : 1010000 } , { context_length : 262144 } ] ,
77+ } ,
78+ {
79+ id : "test/reversed-provider-order" ,
80+ providers : [ { context_length : 262144 } , { context_length : 1010000 } ] ,
81+ } ,
82+ {
83+ id : bundledModel . id ,
84+ providers : [
85+ { status : "error" , context_length : 16000 } ,
86+ { context_length : 96000 } ,
87+ { context_length : 0 } ,
88+ { context_length : 64000 } ,
89+ ] ,
90+ } ,
91+ ] ,
92+ } ) ,
93+ ) ,
94+ ) ;
95+
96+ const models = await discoverHuggingfaceModels ( "hf_test_token" ) ;
97+
98+ expect ( models . map ( ( { id, contextWindow } ) => ( { id, contextWindow } ) ) ) . toEqual ( [
99+ { id : "Qwen/Qwen3.8-2.4T-A95B" , contextWindow : 262144 } ,
100+ { id : "test/reversed-provider-order" , contextWindow : 262144 } ,
101+ { id : bundledModel . id , contextWindow : 64000 } ,
102+ ] ) ;
103+ } ) ;
104+
67105 it ( "disables tools only when every available route explicitly rejects them" , async ( ) => {
68106 vi . stubGlobal (
69107 "fetch" ,
@@ -108,7 +146,7 @@ describe("huggingface models", () => {
108146 {
109147 id : "test/no-tools-vision" ,
110148 input : [ "text" , "image" ] ,
111- contextWindow : 96000 ,
149+ contextWindow : 64000 ,
112150 compat : { supportsTools : false } ,
113151 } ,
114152 {
0 commit comments