Repository navigation
fix(server): fail V2 turns when the OpenCode event stream ends - #9905
Merged
juliusmarminge merged 1 commit intoSep 10, 2026
Merged
juliusmarminge merged 1 commit into
juliusmarminge merged 1 commit into
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
startTurnyields several times afterward while emitting the running turn/thread/session updates before it reachessession.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 callsclient.session.promptAsync, so OpenCode can execute an untracked prompt after callers have received a terminal transport failure. RechecknativeStreamFailure/turn.finalizedimmediately before dispatching the prompt (or abort the admission controller during finalization). [ Already posted ] - line 3201:
session.summarizeis 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 laternativeStreamFailurecheck only suppresses the completion item, not the request. [ Already posted ] - line 3211: The
nativeStreamFailure/turn.finalizedcondition is checked before yielding intoemitCompactionItem. A compaction response can pass this check, suspend at itsDateTime.now, then the EOF fiber can setnativeStreamFailure; if the compaction fiber resumes before EOF finalization closesevents, it emits a completed compaction item even though the subsequentfinalizeTurnreports the turn as failed. The check must be performed atomically with, or inside, the item emission. [ Already posted ]
Loading