[codex] Make active turn task singular#24105
Conversation
|
@codex review this |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88e728326f
ℹ️ 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".
| _timer: timer, | ||
| }; | ||
| turn.add_task(running_task); | ||
| turn.task = Some(running_task); |
There was a problem hiding this comment.
Can we conditionally install only if the reserved turn state is still current, and otherwise bail/cleanup?
start_task has awaits between the empty active-turn reservation and installing the task, so if that reservation gets stolen by a user turn, this assignment can overwrite the new active task in release builds.
I don't think this can happen right now but it would be better to be loud/clean if this primitive changes in the future (because we know how stable primitives are...)
Why
ActiveTurnalready runs at most one task: starting a task requires that no task is present, and replacement aborts existing work first. Representing that state as anIndexMapleaves a multi-task shape for a single-task invariant and makes each lifecycle lookup operate like a collection lookup.The slot remains optional because goal continuation uses an empty active turn as a reservation while deciding whether to start continuation work.
What changed
ActiveTurn.taskswithtask: Option<RunningTask>.Validation
cargo test -p codex-core --lib session::tests::steer_inputcargo test -p codex-core --lib session::tests::abort_empty_active_turn_preserves_pending_inputcargo test -p codex-core --lib session::tests::queued_response_items_for_next_turn_move_into_next_active_turncargo test -p codex-core --lib session::tests::active_goal_continuation_runs_again_after_no_tool_turncargo test -p codex-core --lib session::tests::abort_regular_task_emits_turn_aborted_onlycargo test -p codex-core --lib session::input_queue::tests