fix(server): mark restart-recovered turns running after sendTurn - #459
Merged
Conversation
After a deploy/restart, continuation prepared the session as starting with no activeTurnId and waited for turn.started. Codex resume often never emits that until the replacement turn ends, so queue.steer stayed blocked for the whole turn. Adopt the sendTurn turn id as running.
patroza
marked this pull request as ready for review
September 7, 2026 07:43
Fork CI Test failed with an unhandled cancelAnimationFrame after WorkerPoolManager broadcast ran from a leftover setImmediate once globals were unstubbed. Track and clear those frames the same way the highlight tests already do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Problem
After a deploy/restart,
reconcileProviderSessionsresumes interrupted threads by preparing the orchestration session asstartingwithactiveTurnId: null, then callingsendTurn. It previously left the session in that starting state until the provider emittedturn.started.Codex resume (
thread/resume) often does not emitturn.starteduntil the replacement turn finishes. Meanwhilethread.queue.steerrefuses with “still starting a turn”, so queued messages and Send now stay blocked for the whole recovered turn.This showed up after the #457/#458 upgrade: upstream
#10421made restart resume fire without requiring the directoryactiveTurnIdto match the projection turn, so more in-flight threads recover after a service restart. The stuck-in-starting gap was already in fork recovery; the update just made resume kick in.Fix
After a successful recovery
sendTurn, dispatchthread.session.setwithstatus: "running"andactiveTurnId: result.turnId. Prepare still uses starting/null (short window). FailedsendTurnstill settles error.Test
serverRuntimeStartup.reconcile.test.tsnow asserts both the preparestartingsets and the post-sendTurnrunningsets with the admitted turn ids.