fix(realtime): keep the server's status when converting a conversation item - #4601
Closed
ProjeetBhaumik wants to merge 1 commit into
Closed
fix(realtime): keep the server's status when converting a conversation item#4601ProjeetBhaumik wants to merge 1 commit into
ProjeetBhaumik wants to merge 1 commit into
Conversation
…n item conversation_item_to_realtime_message_item hardcoded "in_progress", so the status on the server payload was dropped. In a default voice session the handler for conversation.item.input_audio_transcription.completed retrieves _current_item_id, which after assistant audio is the assistant's item. The server replies with conversation.item.retrieved carrying status "completed", the conversion rewrote it to "in_progress", and the history merge keeps the incoming status — so a completed item regressed on every user turn, with nothing to restore it. conversation.item.truncated triggers the same retrieve. Pass item.status through, falling back to "in_progress" only when the server omits it. This matches what _handle_ws_event already does for response.output_item.added/done. Fixes openai#4597
Member
|
This PR implements the same explicit-status pass-through as #4598, but #4598 already covers the realistic audio/transcription-triggered retrieve path and is the selected destination for the remaining session-history regression test. To avoid maintaining parallel candidates for the same fix, I am going to close #4601 as a duplicate of #4598. |
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.
This pull request fixes a realtime history regression where completed conversation items flip back to
in_progress._ConversionHelper.conversation_item_to_realtime_message_itemhardcoded"status": "in_progress", discarding the status carried by the server payload.This is reachable in a default voice session. After the assistant produces audio,
_current_item_idpoints at the assistant's audio item. When the user's next utterance finishes transcription, the handler forconversation.item.input_audio_transcription.completedsendsconversation.item.retrievefor that item, and the server replies withconversation.item.retrievedcarrying the item's real status (completed). The conversion rewrote it toin_progress, and the session history merge keeps the incoming status, so a completed assistant item regressed on every user turn with nothing to restore it.conversation.item.truncatedtriggers the same retrieve.The fix passes
item.statusthrough, falling back to"in_progress"only when the server omits it. The GA conversation item models (RealtimeConversationItem{User,Assistant,System}Message) all declarestatus: Literal["in_progress", "completed", "incomplete"] | None, so the value is already on the parsed item. This matches what_handle_ws_eventalready does forresponse.output_item.added/.done, which reads the payload's status and only synthesizes one when it is absent.Behavior note: items whose status the server does report now surface that status instead of a fabricated
in_progress. That also applies to user and system items, which do not declarestatuson the SDK model and carry it as an extra field.Fixes #4597