codex - 💡(How to fix) Fix Bug: Review turns lack TurnStarted event, inconsistent with other task types

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

In codex-rs/core/src/session/review.rs lines 152-154, there is a known inconsistency:

// TODO(ccunningham): Review turns currently rely on `spawn_task` for TurnComplete but do not
// 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;

Review turns emit TurnComplete but not TurnStarted, making them inconsistent with all other task types. This means:

  1. Clients/UIs that track turn state via TurnStarted + TurnComplete pairs will have mismatched state for review turns.
  2. Event consumers expecting a TurnStarted before TurnComplete will see an orphaned TurnComplete event.
  3. This could cause issues in the TUI or any external client listening to the event stream.

Root Cause

In codex-rs/core/src/session/review.rs lines 152-154, there is a known inconsistency:

// TODO(ccunningham): Review turns currently rely on `spawn_task` for TurnComplete but do not
// 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;

Review turns emit TurnComplete but not TurnStarted, making them inconsistent with all other task types. This means:

  1. Clients/UIs that track turn state via TurnStarted + TurnComplete pairs will have mismatched state for review turns.
  2. Event consumers expecting a TurnStarted before TurnComplete will see an orphaned TurnComplete event.
  3. This could cause issues in the TUI or any external client listening to the event stream.

Code Example

// TODO(ccunningham): Review turns currently rely on `spawn_task` for TurnComplete but do not
// 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;
RAW_BUFFERClick to expand / collapse

Description

In codex-rs/core/src/session/review.rs lines 152-154, there is a known inconsistency:

// TODO(ccunningham): Review turns currently rely on `spawn_task` for TurnComplete but do not
// 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;

Review turns emit TurnComplete but not TurnStarted, making them inconsistent with all other task types. This means:

  1. Clients/UIs that track turn state via TurnStarted + TurnComplete pairs will have mismatched state for review turns.
  2. Event consumers expecting a TurnStarted before TurnComplete will see an orphaned TurnComplete event.
  3. This could cause issues in the TUI or any external client listening to the event stream.

Suggested fix

Emit TurnStarted before spawn_task for review turns, matching the lifecycle of other task types.

Environment

  • File: codex-rs/core/src/session/review.rs, lines 145-164

extent analysis

TL;DR

Emit a TurnStarted event before spawning the review task to ensure consistency with other task types.

Guidance

  • Identify the location of the inconsistency in codex-rs/core/src/session/review.rs lines 152-154 and understand the current behavior of review turns.
  • Consider adding a TurnStarted event emission before the spawn_task call for review turns, as suggested in the issue description.
  • Verify that clients/UIs tracking turn state and event consumers expecting TurnStarted before TurnComplete are updated to handle the new event sequence correctly.
  • Review the event stream handling in the TUI and external clients to ensure they can handle the updated event sequence.

Example

// Before spawning the review task, emit a TurnStarted event
sess.emit_event(TurnStarted { /* event data */ }).await;
sess.spawn_task(tc.clone(), input, ReviewTask::new()).await;

Notes

The suggested fix assumes that the TurnStarted event is properly defined and handled by the event consumers. Additional testing may be required to ensure the updated event sequence does not introduce new issues.

Recommendation

Apply the suggested workaround by emitting a TurnStarted event before spawning the review task, as this will ensure consistency with other task types and fix the known inconsistency.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Bug: Review turns lack TurnStarted event, inconsistent with other task types