fix(server): stop Codex threads with queued follow-ups - #5762
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codex stop requests failed when a thread had a queued follow-up. T3 replaced the active provider turn ID with the queued turn ID, so Codex rejected the interrupt.
Keep the existing active turn ID until Codex sends turn lifecycle notifications that advance it. The integration test reproduces the observed active and queued turn ordering.
Test:
vp test run apps/server/src/provider/Layers/CodexCollabRuntime.integration.test.tsCreated by GPT-5.6 in T3 Code using the Codex harness.
Note
Medium Risk
Changes turn-tracking used by Stop/interrupt on the Codex provider path; scope is narrow and covered by a new integration test, but incorrect active-turn bookkeeping could still break interrupt behavior.
Overview
Stop on Codex threads failed when a follow-up was queued while the current turn was still running: each
turn/startresponse overwroteactiveTurnIdwith the queued turn id, but Codexturn/interruptonly accepts the currently active turn.sendTurnnow keeps the existingactiveTurnIdwhen Codex returns a queued follow-up (session.activeTurnId ?? turnId); lifecycle handlers (turn/started/turn/completed) still advance or clear it.updateSessionaccepts an updater function so that logic can read the prior session state.Adds an integration test (two
sendTurncalls, theninterruptTurn) and extends the collab mock peer with per-call turn ids, optional suppression of a secondturn/started, and interrupt validation when the wrong turn id is sent.Reviewed by Cursor Bugbot for commit 84f5321. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
interruptTurnto target the active turn when Codex has a queued follow-upturn/start,session.activeTurnIdwas being overwritten with the new (queued) turn id, causing subsequent interrupts to target the wrong turn.updateSessioncalls in theturn/startflow to a functional form that preserves the existingactiveTurnIdif one is already set.codexCollabMockPeer.mjsto support deterministic turn ids, suppressingturn/startedfor queued turns, and validating interrupt targets.CodexCollabRuntime.integration.test.tsthat reproduces the bug and asserts the interrupt targets the first (active) turn id.📊 Macroscope summarized 84f5321. 2 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.