@@ -348,6 +348,11 @@ function resolveProbeThrottleKey(provider: string, agentDir?: string): string {
348348 return scope ? `${ scope } ${ PROBE_SCOPE_DELIMITER } ${ provider } ` : provider ;
349349}
350350
351+ function isProbeThrottleOpen ( now : number , throttleKey : string ) : boolean {
352+ const lastProbe = lastProbeAttempt . get ( throttleKey ) ?? 0 ;
353+ return now - lastProbe >= MIN_PROBE_INTERVAL_MS ;
354+ }
355+
351356function shouldProbePrimaryDuringCooldown ( params : {
352357 isPrimary : boolean ;
353358 hasFallbackCandidates : boolean ;
@@ -360,8 +365,7 @@ function shouldProbePrimaryDuringCooldown(params: {
360365 return false ;
361366 }
362367
363- const lastProbe = lastProbeAttempt . get ( params . throttleKey ) ?? 0 ;
364- if ( params . now - lastProbe < MIN_PROBE_INTERVAL_MS ) {
368+ if ( ! isProbeThrottleOpen ( params . now , params . throttleKey ) ) {
365369 return false ;
366370 }
367371
@@ -429,11 +433,15 @@ function resolveCooldownDecision(params: {
429433 }
430434
431435 // Billing is semi-persistent: the user may fix their balance, or a transient
432- // 402 might have been misclassified. Probe the primary only when fallbacks
433- // exist; otherwise repeated single-provider probes just churn the disabled
434- // auth state without opening any recovery path .
436+ // 402 might have been misclassified. Probe single-provider setups on the
437+ // standard throttle so they can recover without a restart; when fallbacks
438+ // exist, only probe near cooldown expiry so the fallback chain stays preferred .
435439 if ( inferredReason === "billing" ) {
436- if ( params . isPrimary && params . hasFallbackCandidates && shouldProbe ) {
440+ const shouldProbeSingleProviderBilling =
441+ params . isPrimary &&
442+ ! params . hasFallbackCandidates &&
443+ isProbeThrottleOpen ( params . now , params . probeThrottleKey ) ;
444+ if ( params . isPrimary && ( shouldProbe || shouldProbeSingleProviderBilling ) ) {
437445 return { type : "attempt" , reason : inferredReason , markProbe : true } ;
438446 }
439447 return {
0 commit comments