Skip to content

fix(realtime): #2940 emit history_added / history_updated on transcript_delta#3025

Draft
abhicris wants to merge 1 commit intoopenai:mainfrom
abhicris:fix/realtime-emit-history-on-transcript-delta
Draft

fix(realtime): #2940 emit history_added / history_updated on transcript_delta#3025
abhicris wants to merge 1 commit intoopenai:mainfrom
abhicris:fix/realtime-emit-history-on-transcript-delta

Conversation

@abhicris
Copy link
Copy Markdown
Contributor

@abhicris abhicris commented Apr 25, 2026

Closes #2940.

Bug

RealtimeSession.on_event updates self._history on transcript_delta but only forwards the raw model event to the queue. UIs that follow the documented history_added / history_updated contract therefore never see live partial-transcript changes — even though the session history has already changed.

The repro in the issue shows that after a single RealtimeModelTranscriptDeltaEvent, the queue carries the raw event but no RealtimeHistoryAdded / RealtimeHistoryUpdated.

Fix

Mirror the pattern already used for input_audio_transcription_completed (lines 283-294 of the same file): capture the pre-update history length, apply _get_new_history, and emit:

  • RealtimeHistoryAdded if a brand-new item was appended (first transcript delta for an item), or
  • RealtimeHistoryUpdated otherwise (subsequent partial-transcript update).
         elif event.type == "transcript_delta":
             item_id = event.item_id
             if item_id not in self._item_transcripts:
                 self._item_transcripts[item_id] = ""
                 self._item_guardrail_run_counts[item_id] = 0

             self._item_transcripts[item_id] += event.delta
+            prev_len = len(self._history)
             self._history = self._get_new_history(
                 self._history,
                 AssistantMessageItem(
                     item_id=item_id,
                     content=[AssistantAudio(transcript=self._item_transcripts[item_id])],
                 ),
             )
+            if len(self._history) > prev_len and len(self._history) > 0:
+                await self._put_event(
+                    RealtimeHistoryAdded(info=self._event_info, item=self._history[-1])
+                )
+            else:
+                await self._put_event(
+                    RealtimeHistoryUpdated(info=self._event_info, history=self._history)
+                )

Both events are already imported (lines 36-37) and used elsewhere in the file. No new state, no public-API change.

+13 / 0. Guardrail-debounce logic below this block is unaffected.


Contributed by kcolbchain.

…ta (closes openai#2940)

`RealtimeSession.on_event` updated `self._history` on `transcript_delta` but
only forwarded the raw model event to the queue. UIs that follow the
documented `history_added` / `history_updated` contract therefore never saw
live partial-transcript changes — even though the session history had
already changed.

Mirror the pattern already used for `input_audio_transcription_completed`
(lines 283-294 of the same file): capture the pre-update history length,
apply `_get_new_history`, and emit `RealtimeHistoryAdded` if a brand-new
item was appended (first transcript delta for an item) or
`RealtimeHistoryUpdated` otherwise (subsequent partial-transcript update).

Both events are already imported (lines 36-37) and used elsewhere in the
file. No new state, no public-API change.
@github-actions github-actions Bot added bug Something isn't working feature:realtime labels Apr 25, 2026
@seratch seratch changed the title fix(realtime): emit history_added / history_updated on transcript_delta fix(realtime): #2940 emit history_added / history_updated on transcript_delta Apr 25, 2026
@seratch seratch marked this pull request as draft April 27, 2026 00:54
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions Bot added the stale label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:realtime stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RealtimeSession does not emit history_updated for transcript_delta

1 participant