Skip to content

fix(server): stop Codex threads with queued follow-ups - #5762

Merged
t3dotgg merged 1 commit into
mainfrom
t3code/fix-codex-stop-behavior
Aug 9, 2026
Merged

fix(server): stop Codex threads with queued follow-ups#5762
t3dotgg merged 1 commit into
mainfrom
t3code/fix-codex-stop-behavior

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Aug 9, 2026

Copy link
Copy Markdown
Member

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.ts

Created 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/start response overwrote activeTurnId with the queued turn id, but Codex turn/interrupt only accepts the currently active turn.

sendTurn now keeps the existing activeTurnId when Codex returns a queued follow-up (session.activeTurnId ?? turnId); lifecycle handlers (turn/started / turn/completed) still advance or clear it. updateSession accepts an updater function so that logic can read the prior session state.

Adds an integration test (two sendTurn calls, then interruptTurn) and extends the collab mock peer with per-call turn ids, optional suppression of a second turn/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 interruptTurn to target the active turn when Codex has a queued follow-up

  • When Codex accepts a queued follow-up via turn/start, session.activeTurnId was being overwritten with the new (queued) turn id, causing subsequent interrupts to target the wrong turn.
  • Fixes this by switching updateSession calls in the turn/start flow to a functional form that preserves the existing activeTurnId if one is already set.
  • Extends codexCollabMockPeer.mjs to support deterministic turn ids, suppressing turn/started for queued turns, and validating interrupt targets.
  • Adds an integration test in CodexCollabRuntime.integration.test.ts that 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.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant