Feature/OpenAI responses output text phase - #176
Merged
Conversation
…t items Add failing tests for the new field that should be set on assistant OutputText content items when converting messages to the OpenAI Responses API input format (both HTTP/SSE and WebSocket clients). Rules: - phase = "commentary" when the assistant message contains tool use blocks - phase = "final_answer" when the assistant message has no tool use blocks - User InputText items must never carry a phase field Per the OpenAI Responses API docs, the phase label should be preserved and resent on all assistant messages in follow-up requests to avoid performance degradation on models like gpt-5.3-codex and beyond.
Per the OpenAI Responses API documentation, assistant output_text items in the input array should carry a 'phase' label when resending messages in follow-up requests: - 'commentary' — when the message contains tool use blocks - 'final_answer' — when the message has no tool use blocks The field is optional (skip_serializing_if = "is_none") so it is omitted when not applicable (user InputText items, image items, etc.). Changes: - ResponseContentItem::OutputText (HTTP/SSE client): add phase field - WsContentItem::OutputText (WebSocket client): add phase field - convert_messages(): pre-scan blocks for ToolUse to determine phase for simple text messages (always final_answer — no tool use possible) - convert_structured_message(): pre-scan blocks for ToolUse, assign matching phase to every OutputText item in that message - response_blocks_to_input_items() (WS): same pre-scan logic applied when converting server response blocks back to input items for incremental request delta tracking - Existing tests updated for new struct field (use .. to ignore phase where the value is not the focus of the test)
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.
See https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(model)%20response_output_message%20%3E%20(schema)%20%3E%20(property)%20phase