fix(server): keep codex turn ids aligned - #106
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9674cdd679
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| updated.delete(threadId); | ||
| return updated; | ||
| }); | ||
| const rootTurn = yield* Deferred.await(turnStarted); |
There was a problem hiding this comment.
Stop waiting when Codex exits before turn/started
When Codex returns a successful turn/start response and then exits or emits an invalid/missing turn/started notification, this local deferred is never completed or failed. The existing replay preamble in CodexAdapterV2.test.ts explicitly permits the response to arrive before the notification, so an exit in that interval leaves startTurn suspended indefinitely, the run stuck during startup, and the provider session marked busy; race this wait against transport termination or otherwise provide a failure path.
Useful? React with 👍 / 👎.
| if (started.turn.id !== rootTurn.nativeTurnId) { | ||
| yield* Effect.logWarning("orchestration-v2.codex-turn-id-mismatch", { | ||
| nativeThreadId: threadId, | ||
| responseNativeTurnId: started.turn.id, | ||
| notificationNativeTurnId: rootTurn.nativeTurnId, | ||
| }); |
There was a problem hiding this comment.
Add coverage for divergent Codex turn IDs
This backend behavior change has no focused regression test: the existing replay preamble supplies the same ID in the turn/start response and turn/started notification, so it cannot prove that provider events and later steering use the notification ID when the two diverge. Add a fixture with distinct IDs and assert that the registered provider turn and expectedTurnId follow the notification.
AGENTS.md reference: AGENTS.md:L110-L110
Useful? React with 👍 / 👎.
What Changed
turn/startednotification, which carries the ID Codex uses for later events.turn/startresponse returns a different ID.Why
Codex 0.145.0 can return a turn ID from
turn/startthat differs from theturn/startednotification during persistent-goal continuation. The adapter treated the response ID as strong, so it dropped later messages and tool events and sent a staleexpectedTurnIdwhen steering.Checklist
Model: GPT-5.6; harness: T3 Code.