| … | … | @@ -6431,6 +6448,46 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* ( | |
| 6455 | + | state: ActiveCodexProviderRetry, | |
| 6456 | + | errorInfo: CodexErrorInfo | null | undefined, | |
| 6457 | + | ) { | |
| 6458 | + | if ((yield* Ref.get(providerRetries)).get(context.providerTurnId) !== state) return; | |
🟠High Adapters/CodexAdapterV2.ts:6458
A stalled retry can interrupt a recovered turn or prematurely terminate a newer retry. The identity check at line 6458 runs before finalizeCodexTurn acquires turnTerminalizationPermit, so another fiber can complete the retry or replace it while this fiber waits; finalizeCodexTurn then proceeds without rechecking the retry identity. Move the identity check and failure assignment into the same terminalization critical section.
No longer relevant as of e45aa316e224de55e683248a1452909192d762e2
Note
Written by claude-opus-5-5 on behalf of Maria
Fixed in fa405b4eed. The identity check and the latestProviderFailure write now run inside finalizeCodexTurn under turnTerminalizationPermit (stalledRetry input), so a retry that was cleared or replaced while the timer waited makes finalize return false.
I can’t verify the fix yet: the available code snapshot is at 8580438 and doesn’t include fa405b4eed.