Skip to content

Feature/OpenAI responses output text phase - #176

Merged
stippi merged 2 commits into
mainfrom
feature/openai-responses-output-text-phase
Jul 31, 2026
Merged

Feature/OpenAI responses output text phase#176
stippi merged 2 commits into
mainfrom
feature/openai-responses-output-text-phase

Conversation

stippi added 2 commits July 31, 2026 16:35
…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)
@stippi
stippi merged commit f03edf4 into main Jul 31, 2026
5 checks passed
@stippi
stippi deleted the feature/openai-responses-output-text-phase branch July 31, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant