@@ -1100,6 +1100,54 @@ describe("runWithModelFallback", () => {
11001100 expect ( result . attempts ) . toStrictEqual ( [ ] ) ;
11011101 } ) ;
11021102
1103+ it ( "lets direct CLI providers bypass stale provider auth cooldowns" , async ( ) => {
1104+ const cfg = makeCfg ( {
1105+ agents : {
1106+ defaults : {
1107+ cliBackends : {
1108+ "claude-cli" : { command : "claude" } ,
1109+ } ,
1110+ model : {
1111+ primary : "claude-cli/opus" ,
1112+ } ,
1113+ } ,
1114+ } ,
1115+ } ) ;
1116+ const tempDir = await makeAuthTempDir ( ) ;
1117+ setAuthRuntimeStore ( tempDir , {
1118+ version : AUTH_STORE_VERSION ,
1119+ profiles : {
1120+ "claude-cli:default" : {
1121+ type : "api_key" ,
1122+ provider : "claude-cli" ,
1123+ key : "test-key" ,
1124+ } ,
1125+ "openai:default" : { type : "api_key" , provider : "openai" , key : "test-key" } ,
1126+ } ,
1127+ usageStats : {
1128+ "claude-cli:default" : {
1129+ disabledUntil : Date . now ( ) + 60_000 ,
1130+ disabledReason : "billing" ,
1131+ failureCounts : { rate_limit : 4 } ,
1132+ } ,
1133+ } ,
1134+ } ) ;
1135+ const run = vi . fn ( ) . mockResolvedValueOnce ( "direct cli ok" ) ;
1136+
1137+ const result = await runWithModelFallback ( {
1138+ cfg,
1139+ provider : "claude-cli" ,
1140+ model : "opus" ,
1141+ agentDir : tempDir ,
1142+ run,
1143+ } ) ;
1144+
1145+ expect ( result . result ) . toBe ( "direct cli ok" ) ;
1146+ expect ( run ) . toHaveBeenCalledTimes ( 1 ) ;
1147+ expect ( run . mock . calls [ 0 ] ) . toEqual ( [ "claude-cli" , "opus" ] ) ;
1148+ expect ( result . attempts ) . toStrictEqual ( [ ] ) ;
1149+ } ) ;
1150+
11031151 it ( "does not treat command-lane watchdog timeouts as model fallback failures" , async ( ) => {
11041152 const cfg = makeCfg ( ) ;
11051153 const timeoutError = new CommandLaneTaskTimeoutError ( "cron-nested" , 330_000 ) ;
0 commit comments