Update realtime handoff transcript handling#18597
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bda8b952ba
ℹ️ 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".
| if text.is_empty() || contains_transcript_entry(entries, role, &text) { | ||
| return; |
There was a problem hiding this comment.
Preserve repeated utterances in active transcript
Avoid de-duplicating transcript entries by (role,text) across the whole history. contains_transcript_entry causes later repeated phrases (e.g. user says the same request again) to be dropped, so active_transcript is no longer a full chronological transcript and handoff context can omit the latest utterance.
Useful? React with 👍 / 👎.
| item.get("id") | ||
| .and_then(Value::as_str) | ||
| .map(str::to_string) | ||
| .map(|item_id| RealtimeEvent::ConversationItemDone { item_id }) |
There was a problem hiding this comment.
Restore transcript handling for conversation.item.done
conversation.item.done no longer maps message content to Input/OutputTranscriptDone; it now returns only ConversationItemDone. When providers send finalized text only in this event, transcript text is lost because downstream transcript accumulation ignores ConversationItemDone, breaking handoff context completeness.
Useful? React with 👍 / 👎.
Summary
This PR aims to improve integration between the realtime model and the codex agent by sharing more context with each other. In particular, we now share full realtime conversation transcript deltas in addition to the delegation message.
realtime_conversation.rs now turns a handoff into:
Implementation notes
The transcript is accumulated in the realtime websocket layer as parsed realtime events arrive. When a background-agent handoff is requested, the current transcript snapshot is copied onto the handoff event and then serialized by
realtime_conversation.rsinto the hidden realtime delegation envelope that Codex receives as user-turn context.For Realtime V2, the session now explicitly enables input audio transcription, and the parser handles the relevant input/output transcript completion events so the snapshot includes both user speech and realtime model responses. The delegation
<input>remains the actual handoff request, while<transcript_delta>carries the surrounding conversation history for context.Reviewers should note that the transcript payload is intended for Codex context sharing, not UI rendering. The realtime delegation envelope should stay hidden from the user-facing transcript surface, while still being included in the background-agent turn so Codex can answer with the same conversational context the realtime model had.