@@ -574,29 +574,84 @@ describe('Server Config (config.ts)', () => {
574574 } ) ;
575575 } ) ;
576576
577- describe ( 'UseModelRouter Configuration' , ( ) => {
578- it ( 'should default useModelRouter to false when not provided' , ( ) => {
579- const config = new Config ( baseParams ) ;
577+ describe ( 'Model Router with Auth' , ( ) => {
578+ it ( 'should disable model router by default for oauth-personal' , async ( ) => {
579+ const config = new Config ( {
580+ ...baseParams ,
581+ useModelRouter : true ,
582+ } ) ;
583+ await config . refreshAuth ( AuthType . LOGIN_WITH_GOOGLE ) ;
580584 expect ( config . getUseModelRouter ( ) ) . toBe ( false ) ;
581585 } ) ;
582586
583- it ( 'should set useModelRouter to true when provided as true' , ( ) => {
584- const paramsWithModelRouter : ConfigParameters = {
587+ it ( 'should enable model router by default for other auth types' , async ( ) => {
588+ const config = new Config ( {
585589 ...baseParams ,
586590 useModelRouter : true ,
587- } ;
588- const config = new Config ( paramsWithModelRouter ) ;
591+ } ) ;
592+ await config . refreshAuth ( AuthType . USE_GEMINI ) ;
593+ expect ( config . getUseModelRouter ( ) ) . toBe ( true ) ;
594+ } ) ;
595+
596+ it ( 'should disable model router for specified auth type' , async ( ) => {
597+ const config = new Config ( {
598+ ...baseParams ,
599+ useModelRouter : true ,
600+ disableModelRouterForAuth : [ AuthType . USE_GEMINI ] ,
601+ } ) ;
602+ await config . refreshAuth ( AuthType . USE_GEMINI ) ;
603+ expect ( config . getUseModelRouter ( ) ) . toBe ( false ) ;
604+ } ) ;
605+
606+ it ( 'should enable model router for other auth type' , async ( ) => {
607+ const config = new Config ( {
608+ ...baseParams ,
609+ useModelRouter : true ,
610+ disableModelRouterForAuth : [ ] ,
611+ } ) ;
612+ await config . refreshAuth ( AuthType . LOGIN_WITH_GOOGLE ) ;
589613 expect ( config . getUseModelRouter ( ) ) . toBe ( true ) ;
590614 } ) ;
591615
592- it ( 'should set useModelRouter to false when explicitly provided as false' , ( ) => {
593- const paramsWithModelRouter : ConfigParameters = {
616+ it ( 'should keep model router disabled when useModelRouter is false' , async ( ) => {
617+ const config = new Config ( {
594618 ...baseParams ,
595619 useModelRouter : false ,
596- } ;
597- const config = new Config ( paramsWithModelRouter ) ;
620+ disableModelRouterForAuth : [ AuthType . USE_GEMINI ] ,
621+ } ) ;
622+ await config . refreshAuth ( AuthType . LOGIN_WITH_GOOGLE ) ;
598623 expect ( config . getUseModelRouter ( ) ) . toBe ( false ) ;
599624 } ) ;
625+
626+ it ( 'should keep the user-chosen model after refreshAuth, even when model router is disabled for the auth type' , async ( ) => {
627+ const config = new Config ( {
628+ ...baseParams ,
629+ useModelRouter : true ,
630+ disableModelRouterForAuth : [ AuthType . USE_GEMINI ] ,
631+ } ) ;
632+ const chosenModel = 'gemini-1.5-pro-latest' ;
633+ config . setModel ( chosenModel ) ;
634+
635+ await config . refreshAuth ( AuthType . USE_GEMINI ) ;
636+
637+ expect ( config . getUseModelRouter ( ) ) . toBe ( false ) ;
638+ expect ( config . getModel ( ) ) . toBe ( chosenModel ) ;
639+ } ) ;
640+
641+ it ( 'should keep the user-chosen model after refreshAuth, when model router is enabled for the auth type' , async ( ) => {
642+ const config = new Config ( {
643+ ...baseParams ,
644+ useModelRouter : true ,
645+ disableModelRouterForAuth : [ AuthType . USE_GEMINI ] ,
646+ } ) ;
647+ const chosenModel = 'gemini-1.5-pro-latest' ;
648+ config . setModel ( chosenModel ) ;
649+
650+ await config . refreshAuth ( AuthType . LOGIN_WITH_GOOGLE ) ;
651+
652+ expect ( config . getUseModelRouter ( ) ) . toBe ( true ) ;
653+ expect ( config . getModel ( ) ) . toBe ( chosenModel ) ;
654+ } ) ;
600655 } ) ;
601656
602657 describe ( 'ContinueOnFailedApiCall Configuration' , ( ) => {
0 commit comments