@@ -181,9 +181,11 @@ async function runNovitaToolProbe(
181181 let taskId : string | undefined
182182
183183 try {
184+ const novitaApiKey = aimockUrl && ! isRecord ? "mock-key" : NOVITA_API_KEY
185+
184186 await api . setConfiguration ( {
185187 apiProvider : "novita" as const ,
186- novitaApiKey : aimockUrl && ! isRecord ? "mock-key" : NOVITA_API_KEY ! ,
188+ ... ( novitaApiKey && { novitaApiKey } ) ,
187189 ...( aimockUrl && { novitaBaseUrl : `${ aimockUrl } /v1` } ) ,
188190 apiModelId : modelId ,
189191 } )
@@ -244,9 +246,7 @@ async function runNovitaToolProbe(
244246 mistakeLimitReached,
245247 completionText,
246248 usedReadFile : usedReadFile || transcript . some ( ( line ) => line . includes ( fileName ) ) ,
247- requests : requests . filter (
248- ( request ) => request . model === modelId && ( ! request . probeTag || request . probeTag === probeTag ) ,
249- ) ,
249+ requests : requests . filter ( ( request ) => request . model === modelId && request . probeTag === probeTag ) ,
250250 transcript,
251251 } ,
252252 }
@@ -275,7 +275,9 @@ suite("Novita provider", function () {
275275 const requests : CapturedNovitaRequest [ ] = [ ]
276276
277277 setup ( function ( ) {
278- if ( ! process . env . AIMOCK_URL && ! NOVITA_API_KEY ) {
278+ const needsRealNovitaKey = process . env . AIMOCK_RECORD === "true" || ! process . env . AIMOCK_URL
279+
280+ if ( needsRealNovitaKey && ! NOVITA_API_KEY ) {
279281 this . skip ( )
280282 }
281283 } )
@@ -293,13 +295,15 @@ suite("Novita provider", function () {
293295
294296 const aimockUrl = process . env . AIMOCK_URL
295297 const isRecord = process . env . AIMOCK_RECORD === "true"
298+ const openRouterApiKey = aimockUrl
299+ ? isRecord
300+ ? ( process . env . OPENROUTER_API_KEY ?? "mock-key" )
301+ : "mock-key"
302+ : process . env . OPENROUTER_API_KEY
303+
296304 await globalThis . api . setConfiguration ( {
297305 apiProvider : "openrouter" as const ,
298- openRouterApiKey : aimockUrl
299- ? isRecord
300- ? ( process . env . OPENROUTER_API_KEY ?? "mock-key" )
301- : "mock-key"
302- : process . env . OPENROUTER_API_KEY ! ,
306+ ...( openRouterApiKey && { openRouterApiKey } ) ,
303307 openRouterModelId : "openai/gpt-4.1" ,
304308 ...( aimockUrl && { openRouterBaseUrl : `${ aimockUrl } /v1` } ) ,
305309 } )
@@ -320,9 +324,6 @@ suite("Novita provider", function () {
320324 assert . strictEqual ( result . aborted , false , `Novita task should not abort.\n${ diagnostics } ` )
321325 assert . strictEqual ( result . noToolErrors , 0 , `Novita should not hit MODEL_NO_TOOLS_USED.\n${ diagnostics } ` )
322326 assert . ok ( result . usedReadFile , `Novita should use read_file for the marker file.\n${ diagnostics } ` )
323- assert . ok (
324- ! result . completionText || result . completionText === marker ,
325- `Novita should not return an incorrect marker.\n${ diagnostics } ` ,
326- )
327+ assert . strictEqual ( result . completionText , marker , `Novita should return the exact marker.\n${ diagnostics } ` )
327328 } )
328329} )
0 commit comments