Skip to content

fix(server): fail V2 turns when the OpenCode event stream ends - #9905

Merged
juliusmarminge merged 1 commit into
pingdotgg:t3code/codex-turn-mappingfrom
saphid:fix/v2-opencode-eof-20260905
Sep 10, 2026
Merged

juliusmarminge merged 1 commit into
pingdotgg:t3code/codex-turn-mappingfrom
saphid:fix/v2-opencode-eof-20260905

fix(server): fail V2 turns when the OpenCode event stream ends

49d5625
Select commit
Loading
Failed to load commit list.
MacroscopeApp / Macroscope - Correctness Check succeeded Sep 10, 2026 in 1m 47s

No issues identified (2 code objects reviewed).

• Merge Base: c495cce
• Head: 49d5625

Details

✅ File Path U3 Bytes Comments Posted Reason
➖ apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.test.ts 7180 Excluded by default ignore patterns
✅ apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.ts 4070 0

Billed Total: 10.00KB of diff | $0.50 (This review was charged at our per-review byte minimum of 10.00KB. Learn more here)

Filtered Issues Details

apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.ts
  • line 3142: The second EOF check only protects turn installation, but startTurn yields several times afterward while emitting the running turn/thread/session updates before it reaches session.promptAsync. If EOF is handled during one of those yields, its handler finalizes the newly installed turn as failed; when this fiber resumes it still calls client.session.promptAsync, so OpenCode can execute an untracked prompt after callers have received a terminal transport failure. Recheck nativeStreamFailure/turn.finalized immediately before dispatching the prompt (or abort the admission controller during finalization). [ Already posted ]
  • line 3201: session.summarize is also dispatched after the turn is installed and after several yielding state-update emissions, with no EOF/finalization guard before this call. If the event stream ends during those emissions, the EOF handler marks this compaction turn failed, but this fiber can resume and still compact the remote session. That changes its context despite the caller having received a failed terminal turn; the later nativeStreamFailure check only suppresses the completion item, not the request. [ Already posted ]
  • line 3211: The nativeStreamFailure/turn.finalized condition is checked before yielding into emitCompactionItem. A compaction response can pass this check, suspend at its DateTime.now, then the EOF fiber can set nativeStreamFailure; if the compaction fiber resumes before EOF finalization closes events, it emits a completed compaction item even though the subsequent finalizeTurn reports the turn as failed. The check must be performed atomically with, or inside, the item emission. [ Already posted ]