fix(realtime): preserve existing transcript over stale delta accumulator#3214
Merged
seratch merged 1 commit intoopenai:mainfrom May 8, 2026
Merged
Conversation
When merging an `item_updated` event, the merge logic falls back to the
in-flight `_item_transcripts` delta accumulator only when the existing
history item has no transcript. The previous implementation unconditionally
reassigned `preserved` from the delta dict for assistant items, clobbering
a complete transcript already in history with whatever partial (or stale)
delta state was still around.
This contradicted the inline comment ("If still missing and this is an
assistant item, fall back to ...") and meant a retrieve-without-transcript
update could replace the final transcript with stale partials.
Add the missing `not preserved` guard and a regression test that fails
without the fix.
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While merging a
RealtimeModelItemUpdatedEventwhose incoming content lacks a transcript,RealtimeSessionlooked up the existing item to preserve its transcript, then unconditionally reassigned the localpreservedvariable from the in-flight_item_transcriptsdelta accumulator for assistant items.That contradicted the adjacent comment ("If still missing and this is an assistant item, fall back to ...") and meant a stale or partial delta still buffered for the same
item_idwould clobber the complete transcript already in history. In practice this surfaced when the platform retrieves an item (e.g. afterconversation.item.truncated) without a transcript while delta state from the same turn was still around.The one-line fix adds the missing
not preservedguard so the delta fallback only fires when the existing item really has nothing. The existing two preservation tests still pass; the new regression test fails onmainand passes with the fix.Test plan
pytest tests/realtime/test_session.py::TestTranscriptPreservation(3 passed, including new regression test)pytest tests/realtime/(233 passed, no regressions)mainwithout the fix (assert 'stale partial' == 'Final complete transcript')