FIX bound OpenAI Realtime completion grace - #2420
Open
Roman Lutz (romanlutz) wants to merge 3 commits into
Open
Conversation
Use a one-shot monotonic deadline after audio completion so stale or noisy events cannot indefinitely postpone atomic turn termination. Cover late terminal events, duplicate and stale traffic, and cancellation without real sleeps. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Exercise two turns on one RealtimeTarget conversation against platform and Azure endpoints, asserting websocket reuse and cross-turn context retention. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfe299e4-3111-4ab9-ab9f-46e0dd827f13
Bind atomic receive state to response.created and discard response-scoped events carrying another response ID so late deltas from a soft-finished turn cannot contaminate the next turn. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfe299e4-3111-4ab9-ab9f-46e0dd827f13
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.
Description
OpenAI Realtime atomic event handling started a fresh one-second grace timeout after every event received following
audio.done. Repeated late lifecycle, stale, duplicate, or provider-noise events could therefore postpone completion indefinitely.This change records a one-shot monotonic deadline when the first
audio.donearrives and recomputes only the remaining wait time for later events. Duplicateaudio.doneevents cannot move the deadline, a legitimateresponse.donecan still complete within the grace window, and cancellation continues to propagate. The separate streaming dispatcher path is unchanged because it owns its own event iterator and turn-completion state.Tests and Documentation
Added focused unit coverage for bounded termination under stale/noisy traffic, acceptance of a late terminal event, and cancellation without real sleeping. Also added a live integration test that sends two turns on one conversation and verifies websocket reuse plus cross-turn context on both Platform OpenAI API-key and Azure OpenAI Entra endpoints.
Validation:
git diff --checkpassed.Documentation was not changed because this fixes internal completion timing without changing the public API. JupyText is not applicable.