Skip to content

[codex] Use unique IDs for realtime-routed turns#28826

Merged
guinness-oai merged 1 commit into
mainfrom
guinness/realtime-turn-ids
Jun 18, 2026
Merged

[codex] Use unique IDs for realtime-routed turns#28826
guinness-oai merged 1 commit into
mainfrom
guinness/realtime-turn-ids

Conversation

@guinness-oai

Copy link
Copy Markdown
Collaborator

Why

A durable realtime voice orchestrator can reconnect and resume through multiple fresh Session instances. Realtime handoffs were using the Session-local auto-compact-N counter as their turn identity, but that counter restarts at zero for every resumed Session. The durable thread could therefore accumulate duplicate turn IDs, violating the uniqueness assumptions made by app-server and web clients. In Codex Apps, a new delegated response stream could be attached to an older turn with the same ID, placing live output higher in history and putting turn-scoped actions at risk.

Persisted rollout and reconstructed model-context order were already correct because raw response items remain append-only and chronological. This change restores unique identity for reconstructed and live turn surfaces.

What changed

  • Generate a UUIDv7 specifically for each realtime-routed delegation.
  • Leave the existing auto-compact-N identity path unchanged for actual internal auto-compaction turns.
  • Extend the inbound realtime handoff integration test to require a UUID turn ID from turn/started.

Verification

  • just test -p codex-core inbound_handoff_request_starts_turn
  • just fix -p codex-core
  • just fmt

@guinness-oai guinness-oai marked this pull request as ready for review June 18, 2026 01:45
@guinness-oai guinness-oai requested a review from a team as a code owner June 18, 2026 01:45
@guinness-oai

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d760327b23

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3023 to +3026
let turn_id = loop {
let event = test.codex.next_event().await?;
if let EventMsg::TurnStarted(turn_started) = event.msg {
break turn_started.turn_id;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Capture TurnStarted before it can be discarded

When the routed realtime turn wins the scheduling race, route_realtime_text_input can spawn the task and emit TurnStarted before the fanout sends the HandoffRequested realtime notification; the preceding wait_for_event_match then consumes and drops that TurnStarted, so this loop waits for a second one that never arrives and the test hangs. Capture the turn id in a single event-draining loop (or start waiting for TurnStarted before waiting for the handoff notification) so either event order passes.

Useful? React with 👍 / 👎.

@guinness-oai guinness-oai merged commit a306ac4 into main Jun 18, 2026
46 of 47 checks passed
@guinness-oai guinness-oai deleted the guinness/realtime-turn-ids branch June 18, 2026 02:13
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants