@@ -6173,9 +6173,8 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
61736173
61746174 const attempt = ( context . capacityRetryAttempt ?? 0 ) + 1 ;
61756175 context . capacityRetryAttempt = attempt ;
6176- context . capacityRetryPending = yield * Deferred . make <
6177- ActiveCodexTurnContext | undefined
6178- > ( ) ;
6176+ const pending = yield * Deferred . make < ActiveCodexTurnContext | undefined > ( ) ;
6177+ context . capacityRetryPending = pending ;
61796178 const retryDelayMs = Math . min ( 2_000 * 2 ** ( attempt - 1 ) , 30_000 ) ;
61806179 const now = yield * DateTime . now ;
61816180 const previous = ( yield * Ref . get ( providerRetries ) ) . get ( context . providerTurnId ) ;
@@ -6238,11 +6237,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
62386237 ) . pipe (
62396238 Effect . catch ( ( cause ) =>
62406239 Effect . gen ( function * ( ) {
6241- if (
6242- context . capacityRetryPending !== undefined &&
6243- ( yield * Deferred . isDone ( context . capacityRetryPending ) )
6244- )
6245- return ;
6240+ if ( yield * Deferred . isDone ( pending ) ) return ;
62466241 yield * Effect . logWarning (
62476242 "orchestration-v2.codex-capacity-retry-start-failed" ,
62486243 {
@@ -6260,9 +6255,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
62606255 yield * DateTime . now ,
62616256 ) ,
62626257 } ) ;
6263- if ( context . capacityRetryPending !== undefined ) {
6264- yield * Deferred . succeed ( context . capacityRetryPending , undefined ) ;
6265- }
6258+ yield * Deferred . succeed ( pending , undefined ) ;
62666259 yield * turnTerminalizationPermit . withPermits ( 1 ) (
62676260 emitOrDeferRootTerminal ( { ...terminal , providerRetry : state } ) ,
62686261 ) ;
0 commit comments