fix(server): prevent premature OpenCode turn completion #10805
ClosedNaveDanan(GitHub profile, opens in a new tab)wants to merge 11 commits into
main fromrefs/pull/10805/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/provider/Layers/OpenCodeAdapter.ts lines 1441 to 1449Resolvedby NaveDanan(GitHub profile, opens in a new tab)@@ -1391,3 +1390,13 @@13911390 }13921391 }139313921393+ if (1394+ promptAdmission.messageObserved &&1395+ promptAdmission.idleDuringAdmission === undefined &&1396+ promptAdmission.priorIdle === undefined1397+ ) {1398+ // A persisted prompt proves admission, not completion. OpenCode can1399+ // still report idle before its session loop starts processing it.1400+ context.promptAdmission = undefined;1401+ context.awaitingBusyAfterInterruption = false;1402+ return;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/OpenCodeAdapter.ts lines 1434 to 1450Resolvedby NaveDanan(GitHub profile, opens in a new tab)@@ -1414,0 +1415,21 @@1415+ if (1416+ context.promptAdmission !== promptAdmission ||1417+ context.activeTurnId !== promptAdmission.turnId ||1418+ context.promptGeneration !== promptAdmission.generation ||1419+ promptAdmission.cancelled ||1420+ (yield* Ref.get(context.stopped))1421+ ) {1422+ return;1423+ }1424+1425+ if (1426+ promptAdmission.messageObserved &&1427+ promptAdmission.idleDuringAdmission === undefined &&1428+ promptAdmission.priorIdle === undefined1429+ ) {1430+ // A persisted prompt proves admission, not completion. OpenCode can1431+ // still report idle before its session loop starts processing it.1432+ context.promptAdmission = undefined;1433+ context.awaitingBusyAfterInterruption = false;1434+ return;1435+ }
juliusmarminge added labelsmacroscope-review
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 2236OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2209,0 +2216,21 @@2216+ }2217+ return yield* runOpenCodeSdk("session.messages", (signal) =>2218+ context.client.session.messages(2219+ { sessionID: context.openCodeSessionId, limit: 1 },2220+ { signal },2221+ ),2222+ ).pipe(Effect.timeout("1 second"), Effect.retry({ times: 1 }));2223+ }).pipe(2224+ Effect.tapError((cause) =>2225+ Effect.gen(function* () {2226+ if (warned || !isCurrentPrompt()) return;2227+ warned = true;2228+ yield* emit({2229+ ...(yield* buildEventBase({2230+ threadId: context.session.threadId,2231+ turnId: admission.turnId,2232+ })),2233+ type: "runtime.warning",2234+ payload: {2235+ message: "OpenCode turn completion is waiting for message history.",2236+ detail: openCodeRuntimeErrorDetail(cause),
- apps/server/src/provider/Layers/OpenCodeAdapter.ts line 1441Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1412,3 +1412,21 @@14121412 retryCount = 0;14131413 }14141414 yield* Deferred.await(promptAdmission.acceptance);1415+ if (1416+ context.promptAdmission !== promptAdmission ||1417+ context.activeTurnId !== promptAdmission.turnId ||1418+ context.promptGeneration !== promptAdmission.generation ||1419+ promptAdmission.cancelled ||1420+ (yield* Ref.get(context.stopped))1421+ ) {1422+ return;1423+ }1424+1425+ if (1426+ promptAdmission.messageObserved &&1427+ promptAdmission.idleDuringAdmission === undefined &&1428+ promptAdmission.priorIdle === undefined1429+ ) {1430+ // A persisted prompt proves admission, not completion. OpenCode can1431+ // still report idle before its session loop starts processing it.1432+ context.promptAdmission = undefined;
juliusmarminge closed this
Sign in to join this conversation.
Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
2841bacℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.