[codex] Start idle turns without reservations#24673
Conversation
f74af74 to
354aaee
Compare
|
@codex review this |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 354aaeeccf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| self.abort_all_tasks(TurnAbortReason::Replaced).await; | ||
| self.clear_connector_selection().await; | ||
| self.start_task(turn_context, input, task).await; | ||
| self.try_start_turn_if_idle(turn_context, input, task).await; |
There was a problem hiding this comment.
Start foreground turns even after idle races
replace_turn is used for foreground requests such as user turns and shell commands, but it now delegates to the idle-only try_start_turn_if_idle. If the session is idle after abort_all_tasks and a pending-work or goal-continuation turn starts during the await in clear_connector_selection, this call just returns and the foreground input is neither queued nor run, so the user's request can disappear instead of replacing the background work. Foreground replacement should either win this race or retry/abort the turn that won it.
Useful? React with 👍 / 👎.
| // emit a parent TurnStarted. Consider giving review a full parent turn lifecycle | ||
| // (TurnStarted + TurnComplete) for consistency with other standalone tasks. | ||
| sess.spawn_task(tc.clone(), input, ReviewTask::new()).await; | ||
| sess.replace_turn(tc.clone(), input, ReviewTask).await; |
There was a problem hiding this comment.
Emit review entry before starting the review task
Because replace_turn now returns immediately after spawning the task, the ReviewTask can run to exit_review_mode before this function sends EnteredReviewMode below. In fast failure/cached review paths, clients and replay can observe ExitedReviewMode/TurnComplete before the review-entry marker, leaving the UI/history in the wrong order. Send the entry marker before starting the task, or make task startup wait until the marker is emitted.
Useful? React with 👍 / 👎.
d946761 to
083daf4
Compare
083daf4 to
cacb192
Compare
Why
Goal continuation currently reserves an
ActiveTurnwithout a running task while it revalidates persisted goal state. That creates a partial-active state just to schedule later work, and gives goals a separate turn-start flow from other idle work.What changed
try_start_turn_if_idleas the shared idle-only entry point, with task construction/spawning instart_turnand task execution inrun_turn.replace_turnpreemptive for user turns, standalone shell commands, compaction, and review.turn_admission_lockso explicit replacement and idle-only startup cannot race during admission without using a tasklessActiveTurnreservation.new_default_turn()for automatic idle wake-ups so they follow one internal turn-id allocation path.Behavior tradeoffs
Validation
git diff --check