fix(realtime): preserve server status on converted message items#3568
Open
code-with-rashid wants to merge 1 commit into
Open
fix(realtime): preserve server status on converted message items#3568code-with-rashid wants to merge 1 commit into
code-with-rashid wants to merge 1 commit into
Conversation
conversation_item_to_realtime_message_item hardcoded "in_progress" for every converted message, so assistant messages the server had already marked "completed" still surfaced as in_progress in history_updated events. Mirror the status reported on the incoming ConversationItem and fall back to "in_progress" only when the server omits it. Fixes openai#1434
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
_ConversionHelper.conversation_item_to_realtime_message_itemhardcoded"status": "in_progress"for every converted message. This path handlesconversation.item.added/created/retrievedevents, so an assistant message the server had already markedcompletedstill surfaced asin_progressinhistory_updatedevents — even after the assistant finished speaking or generating audio.The incoming
ConversationItemalready carries astatus(completed/incomplete/in_progress). This change mirrors that status onto the convertedRealtimeMessageItemand falls back to"in_progress"only when the server omits one. The siblingresponse.output_item.*path already derives status this way, so this also makes the two conversion paths consistent.Test plan
test_message_conversion_preserves_server_status(servercompleted→ convertedcompleted) andtest_message_conversion_defaults_status_when_missing(no server status →in_progress) intests/realtime/test_item_parsing.py.uv run pytest tests/realtime/— 257 passed.make lint,make format, andmypyon the changed file pass clean.Issue number
Closes #1434
Checks
make lintandmake format