feat(responses)!: add in_progress, failed, content part events (#3765)

## Summary
- add schema + runtime support for response.in_progress /
response.failed / response.incomplete
- stream content parts with proper indexes and reasoning slots
- align tests + docs with the richer event payloads

## Testing
- uv run pytest
tests/unit/providers/agents/meta_reference/test_openai_responses.py::test_create_openai_response_with_string_input
- uv run pytest
tests/unit/providers/agents/meta_reference/test_response_conversion_utils.py
This commit is contained in:
Ashwin Bharambe 2025-10-10 07:27:34 -07:00 committed by GitHub
parent a548169b99
commit e039b61d26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 1431 additions and 221 deletions

View file

@ -6240,13 +6240,57 @@ components:
type: string
const: output_text
default: output_text
description: >-
Content part type identifier, always "output_text"
text:
type: string
description: Text emitted for this content part
annotations:
type: array
items:
$ref: '#/components/schemas/OpenAIResponseAnnotations'
description: >-
Structured annotations associated with the text
logprobs:
type: array
items:
type: object
additionalProperties:
oneOf:
- type: 'null'
- type: boolean
- type: number
- type: string
- type: array
- type: object
description: (Optional) Token log probability details
additionalProperties: false
required:
- type
- text
- annotations
title: OpenAIResponseContentPartOutputText
description: >-
Text content within a streamed response part.
OpenAIResponseContentPartReasoningText:
type: object
properties:
type:
type: string
const: reasoning_text
default: reasoning_text
description: >-
Content part type identifier, always "reasoning_text"
text:
type: string
description: Reasoning text supplied by the model
additionalProperties: false
required:
- type
- text
title: OpenAIResponseContentPartReasoningText
description: >-
Reasoning text emitted as part of a streamed response.
OpenAIResponseContentPartRefusal:
type: object
properties:
@ -6254,16 +6298,22 @@ components:
type: string
const: refusal
default: refusal
description: >-
Content part type identifier, always "refusal"
refusal:
type: string
description: Refusal text supplied by the model
additionalProperties: false
required:
- type
- refusal
title: OpenAIResponseContentPartRefusal
description: >-
Refusal content within a streamed response part.
OpenAIResponseObjectStream:
oneOf:
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseCreated'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseInProgress'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseOutputItemAdded'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseOutputItemDone'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseOutputTextDelta'
@ -6283,11 +6333,14 @@ components:
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseMcpCallCompleted'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseContentPartAdded'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseContentPartDone'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseIncomplete'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseFailed'
- $ref: '#/components/schemas/OpenAIResponseObjectStreamResponseCompleted'
discriminator:
propertyName: type
mapping:
response.created: '#/components/schemas/OpenAIResponseObjectStreamResponseCreated'
response.in_progress: '#/components/schemas/OpenAIResponseObjectStreamResponseInProgress'
response.output_item.added: '#/components/schemas/OpenAIResponseObjectStreamResponseOutputItemAdded'
response.output_item.done: '#/components/schemas/OpenAIResponseObjectStreamResponseOutputItemDone'
response.output_text.delta: '#/components/schemas/OpenAIResponseObjectStreamResponseOutputTextDelta'
@ -6307,13 +6360,15 @@ components:
response.mcp_call.completed: '#/components/schemas/OpenAIResponseObjectStreamResponseMcpCallCompleted'
response.content_part.added: '#/components/schemas/OpenAIResponseObjectStreamResponseContentPartAdded'
response.content_part.done: '#/components/schemas/OpenAIResponseObjectStreamResponseContentPartDone'
response.incomplete: '#/components/schemas/OpenAIResponseObjectStreamResponseIncomplete'
response.failed: '#/components/schemas/OpenAIResponseObjectStreamResponseFailed'
response.completed: '#/components/schemas/OpenAIResponseObjectStreamResponseCompleted'
"OpenAIResponseObjectStreamResponseCompleted":
type: object
properties:
response:
$ref: '#/components/schemas/OpenAIResponseObject'
description: The completed response object
description: Completed response object
type:
type: string
const: response.completed
@ -6331,6 +6386,10 @@ components:
"OpenAIResponseObjectStreamResponseContentPartAdded":
type: object
properties:
content_index:
type: integer
description: >-
Index position of the part within the content array
response_id:
type: string
description: >-
@ -6339,15 +6398,21 @@ components:
type: string
description: >-
Unique identifier of the output item containing this content part
output_index:
type: integer
description: >-
Index position of the output item in the response
part:
oneOf:
- $ref: '#/components/schemas/OpenAIResponseContentPartOutputText'
- $ref: '#/components/schemas/OpenAIResponseContentPartRefusal'
- $ref: '#/components/schemas/OpenAIResponseContentPartReasoningText'
discriminator:
propertyName: type
mapping:
output_text: '#/components/schemas/OpenAIResponseContentPartOutputText'
refusal: '#/components/schemas/OpenAIResponseContentPartRefusal'
reasoning_text: '#/components/schemas/OpenAIResponseContentPartReasoningText'
description: The content part that was added
sequence_number:
type: integer
@ -6361,8 +6426,10 @@ components:
Event type identifier, always "response.content_part.added"
additionalProperties: false
required:
- content_index
- response_id
- item_id
- output_index
- part
- sequence_number
- type
@ -6373,6 +6440,10 @@ components:
"OpenAIResponseObjectStreamResponseContentPartDone":
type: object
properties:
content_index:
type: integer
description: >-
Index position of the part within the content array
response_id:
type: string
description: >-
@ -6381,15 +6452,21 @@ components:
type: string
description: >-
Unique identifier of the output item containing this content part
output_index:
type: integer
description: >-
Index position of the output item in the response
part:
oneOf:
- $ref: '#/components/schemas/OpenAIResponseContentPartOutputText'
- $ref: '#/components/schemas/OpenAIResponseContentPartRefusal'
- $ref: '#/components/schemas/OpenAIResponseContentPartReasoningText'
discriminator:
propertyName: type
mapping:
output_text: '#/components/schemas/OpenAIResponseContentPartOutputText'
refusal: '#/components/schemas/OpenAIResponseContentPartRefusal'
reasoning_text: '#/components/schemas/OpenAIResponseContentPartReasoningText'
description: The completed content part
sequence_number:
type: integer
@ -6403,8 +6480,10 @@ components:
Event type identifier, always "response.content_part.done"
additionalProperties: false
required:
- content_index
- response_id
- item_id
- output_index
- part
- sequence_number
- type
@ -6417,7 +6496,7 @@ components:
properties:
response:
$ref: '#/components/schemas/OpenAIResponseObject'
description: The newly created response object
description: The response object that was created
type:
type: string
const: response.created
@ -6432,6 +6511,30 @@ components:
OpenAIResponseObjectStreamResponseCreated
description: >-
Streaming event indicating a new response has been created.
OpenAIResponseObjectStreamResponseFailed:
type: object
properties:
response:
$ref: '#/components/schemas/OpenAIResponseObject'
description: Response object describing the failure
sequence_number:
type: integer
description: >-
Sequential number for ordering streaming events
type:
type: string
const: response.failed
default: response.failed
description: >-
Event type identifier, always "response.failed"
additionalProperties: false
required:
- response
- sequence_number
- type
title: OpenAIResponseObjectStreamResponseFailed
description: >-
Streaming event emitted when a response fails.
"OpenAIResponseObjectStreamResponseFunctionCallArgumentsDelta":
type: object
properties:
@ -6504,6 +6607,57 @@ components:
OpenAIResponseObjectStreamResponseFunctionCallArgumentsDone
description: >-
Streaming event for when function call arguments are completed.
"OpenAIResponseObjectStreamResponseInProgress":
type: object
properties:
response:
$ref: '#/components/schemas/OpenAIResponseObject'
description: Current response state while in progress
sequence_number:
type: integer
description: >-
Sequential number for ordering streaming events
type:
type: string
const: response.in_progress
default: response.in_progress
description: >-
Event type identifier, always "response.in_progress"
additionalProperties: false
required:
- response
- sequence_number
- type
title: >-
OpenAIResponseObjectStreamResponseInProgress
description: >-
Streaming event indicating the response remains in progress.
"OpenAIResponseObjectStreamResponseIncomplete":
type: object
properties:
response:
$ref: '#/components/schemas/OpenAIResponseObject'
description: >-
Response object describing the incomplete state
sequence_number:
type: integer
description: >-
Sequential number for ordering streaming events
type:
type: string
const: response.incomplete
default: response.incomplete
description: >-
Event type identifier, always "response.incomplete"
additionalProperties: false
required:
- response
- sequence_number
- type
title: >-
OpenAIResponseObjectStreamResponseIncomplete
description: >-
Streaming event emitted when a response ends in an incomplete state.
"OpenAIResponseObjectStreamResponseMcpCallArgumentsDelta":
type: object
properties: