fix(openai realtime): do not commit a turn the server closed itself - #6965
Open
longcw wants to merge 1 commit into
Open
fix(openai realtime): do not commit a turn the server closed itself#6965longcw wants to merge 1 commit into
longcw wants to merge 1 commit into
Conversation
With server-side turn detection the server commits each segment it detects, but the framework still called commit_audio() on every client turn. Each turn asked the server to close a buffer it had already emptied and logged input_audio_buffer_commit_empty, which #6642 suppressed instead of removing the commit. create_response=False makes this fire on every turn, because the client owns the reply while the server keeps segmenting. The session now tracks the server's own commits and clears the count of pushed audio, so commit_audio() has nothing left to send and keeps its meaning. Only a segment the server closed itself counts: a client commit is acknowledged with the same event, and the audio that arrived while it was in flight is still the client's to commit. The suppression stays for the race where the two commits cross on the wire.
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.
Problem
With server-side turn detection, the server commits each segment that it detects. The framework still calls
commit_audio()on every client turn.Each turn then asks the server to close a buffer that it already emptied, and the server answers with
input_audio_buffer_commit_empty. #6642 suppressed that error and left the commit in place.create_response=Falsemakes this fire on every single turn: the client owns the reply, so it commits and asks for a response, while the server keeps segmenting the audio on its own.Fix
The session now handles
input_audio_buffer.committedand clears the count of pushed audio.commit_audio()then has nothing to send, and its own meaning does not change.Only a segment that the server closed itself counts. A client commit is acknowledged with the same event, and audio that arrived while that commit was in flight is still the client's to commit.
The error suppression stays. A client commit and the server's own can still cross on the wire, and nothing on the client can prevent that.