@@ -263,6 +263,7 @@ export async function preflightCronModelProvider(params: {
263263 let lastError : unknown ;
264264 let attempts = 0 ;
265265 let budgetExhausted = false ;
266+ let cacheableFailure = true ;
266267 for ( let attempt = 1 ; attempt <= maxAttempts ; attempt += 1 ) {
267268 const remainingBudgetMs = resolveRemainingBudgetMs ( params . deadlineMs ) ;
268269 if ( remainingBudgetMs !== undefined && remainingBudgetMs <= 0 ) {
@@ -271,18 +272,24 @@ export async function preflightCronModelProvider(params: {
271272 break ;
272273 }
273274 attempts = attempt ;
275+ const probeTimeoutMs =
276+ remainingBudgetMs === undefined ? timeoutMs : Math . min ( timeoutMs , remainingBudgetMs ) ;
274277 try {
275278 await probeLocalProviderEndpoint ( {
276279 api,
277280 baseUrl,
278- timeoutMs :
279- remainingBudgetMs === undefined ? timeoutMs : Math . min ( timeoutMs , remainingBudgetMs ) ,
281+ timeoutMs : probeTimeoutMs ,
280282 } ) ;
281283 const result : EndpointPreflightResult = { status : "available" } ;
282284 preflightCache . set ( cacheKey , { checkedAtMs : nowMs , result } ) ;
283285 return { status : "available" } ;
284286 } catch ( error ) {
285287 lastError = error ;
288+ // A deadline-clamped probe did not receive the configured health-check
289+ // window, so its failure must not poison the endpoint cache.
290+ if ( probeTimeoutMs < timeoutMs ) {
291+ cacheableFailure = false ;
292+ }
286293 if ( attempt < maxAttempts ) {
287294 const remainingDelayBudgetMs = resolveRemainingBudgetMs ( params . deadlineMs ) ;
288295 if ( remainingDelayBudgetMs !== undefined && remainingDelayBudgetMs <= 0 ) {
@@ -305,7 +312,7 @@ export async function preflightCronModelProvider(params: {
305312 error : lastError ?? new Error ( "cron model preflight chain budget exhausted" ) ,
306313 attempts,
307314 } ;
308- if ( ! budgetExhausted ) {
315+ if ( ! budgetExhausted && cacheableFailure ) {
309316 preflightCache . set ( cacheKey , { checkedAtMs : nowMs , result } ) ;
310317 }
311318 return buildUnavailableResult ( {
0 commit comments