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

@ -10229,10 +10229,71 @@
"type": {
"type": "string",
"const": "output_text",
"default": "output_text"
"default": "output_text",
"description": "Content part type identifier, always \"output_text\""
},
"text": {
"type": "string"
"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,
@ -10240,7 +10301,8 @@
"type",
"text"
],
"title": "OpenAIResponseContentPartOutputText"
"title": "OpenAIResponseContentPartReasoningText",
"description": "Reasoning text emitted as part of a streamed response."
},
"OpenAIResponseContentPartRefusal": {
"type": "object",
@ -10248,10 +10310,12 @@
"type": {
"type": "string",
"const": "refusal",
"default": "refusal"
"default": "refusal",
"description": "Content part type identifier, always \"refusal\""
},
"refusal": {
"type": "string"
"type": "string",
"description": "Refusal text supplied by the model"
}
},
"additionalProperties": false,
@ -10259,13 +10323,17 @@
"type",
"refusal"
],
"title": "OpenAIResponseContentPartRefusal"
"title": "OpenAIResponseContentPartRefusal",
"description": "Refusal content within a streamed response part."
},
"OpenAIResponseObjectStream": {
"oneOf": [
{
"$ref": "#/components/schemas/OpenAIResponseObjectStreamResponseCreated"
},
{
"$ref": "#/components/schemas/OpenAIResponseObjectStreamResponseInProgress"
},
{
"$ref": "#/components/schemas/OpenAIResponseObjectStreamResponseOutputItemAdded"
},
@ -10323,6 +10391,12 @@
{
"$ref": "#/components/schemas/OpenAIResponseObjectStreamResponseContentPartDone"
},
{
"$ref": "#/components/schemas/OpenAIResponseObjectStreamResponseIncomplete"
},
{
"$ref": "#/components/schemas/OpenAIResponseObjectStreamResponseFailed"
},
{
"$ref": "#/components/schemas/OpenAIResponseObjectStreamResponseCompleted"
}
@ -10331,6 +10405,7 @@
"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",
@ -10350,6 +10425,8 @@
"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"
}
}
@ -10359,7 +10436,7 @@
"properties": {
"response": {
"$ref": "#/components/schemas/OpenAIResponseObject",
"description": "The completed response object"
"description": "Completed response object"
},
"type": {
"type": "string",
@ -10379,6 +10456,10 @@
"OpenAIResponseObjectStreamResponseContentPartAdded": {
"type": "object",
"properties": {
"content_index": {
"type": "integer",
"description": "Index position of the part within the content array"
},
"response_id": {
"type": "string",
"description": "Unique identifier of the response containing this content"
@ -10387,6 +10468,10 @@
"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": [
{
@ -10394,13 +10479,17 @@
},
{
"$ref": "#/components/schemas/OpenAIResponseContentPartRefusal"
},
{
"$ref": "#/components/schemas/OpenAIResponseContentPartReasoningText"
}
],
"discriminator": {
"propertyName": "type",
"mapping": {
"output_text": "#/components/schemas/OpenAIResponseContentPartOutputText",
"refusal": "#/components/schemas/OpenAIResponseContentPartRefusal"
"refusal": "#/components/schemas/OpenAIResponseContentPartRefusal",
"reasoning_text": "#/components/schemas/OpenAIResponseContentPartReasoningText"
}
},
"description": "The content part that was added"
@ -10418,8 +10507,10 @@
},
"additionalProperties": false,
"required": [
"content_index",
"response_id",
"item_id",
"output_index",
"part",
"sequence_number",
"type"
@ -10430,6 +10521,10 @@
"OpenAIResponseObjectStreamResponseContentPartDone": {
"type": "object",
"properties": {
"content_index": {
"type": "integer",
"description": "Index position of the part within the content array"
},
"response_id": {
"type": "string",
"description": "Unique identifier of the response containing this content"
@ -10438,6 +10533,10 @@
"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": [
{
@ -10445,13 +10544,17 @@
},
{
"$ref": "#/components/schemas/OpenAIResponseContentPartRefusal"
},
{
"$ref": "#/components/schemas/OpenAIResponseContentPartReasoningText"
}
],
"discriminator": {
"propertyName": "type",
"mapping": {
"output_text": "#/components/schemas/OpenAIResponseContentPartOutputText",
"refusal": "#/components/schemas/OpenAIResponseContentPartRefusal"
"refusal": "#/components/schemas/OpenAIResponseContentPartRefusal",
"reasoning_text": "#/components/schemas/OpenAIResponseContentPartReasoningText"
}
},
"description": "The completed content part"
@ -10469,8 +10572,10 @@
},
"additionalProperties": false,
"required": [
"content_index",
"response_id",
"item_id",
"output_index",
"part",
"sequence_number",
"type"
@ -10483,7 +10588,7 @@
"properties": {
"response": {
"$ref": "#/components/schemas/OpenAIResponseObject",
"description": "The newly created response object"
"description": "The response object that was created"
},
"type": {
"type": "string",
@ -10500,6 +10605,33 @@
"title": "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": {
@ -10574,6 +10706,60 @@
"title": "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": {