Skip to content

Conversation

@DeagleGross
Copy link
Contributor

Reformatted event sequence in streaming responses as per spec example: https://platform.openai.com/docs/api-reference/responses/create

image

@DeagleGross DeagleGross self-assigned this Oct 17, 2025
Copilot AI review requested due to automatic review settings October 17, 2025 11:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Reformats the streaming response event sequence to align with the OpenAI Responses API spec by introducing additional intermediate event types and altering the emitted event order.

  • Adds new streaming event model classes (content part, text delta/done, in-progress).
  • Adjusts processor logic to emit the new event sequence.
  • Removes prior output_item.added emission but still emits output_item.done (likely unintended).

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
ResponseStreamEvent.cs Adds new derived streaming event classes and updates polymorphic type registrations.
AIAgentResponsesProcessor.cs Modifies streaming emission logic to use new event types and revised sequencing.

using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.AI;
using OpenAI.Responses;
using ChatMessage = Microsoft.Extensions.AI.ChatMessage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

{
var sequenceNumber = 1;
var outputIndex = 1;
Dictionary<string, int> messageIdOutputIndexes = new();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
Dictionary<string, int> messageIdOutputIndexes = new();
Dictionary<string, int> messageIdOutputIndexes = [];

CreatedAt = update.CreatedAt,
RawRepresentation = update.RawRepresentation
};
var messageId = chatMessage.MessageId ?? "<null>";
Copy link
Member

@stephentoub stephentoub Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this using "<null>"? Is that just an arbitrary sentinel to use to group together all messages without IDs?

@ReubenBond
Copy link
Member

This is superseded by #1550

@DeagleGross
Copy link
Contributor Author

was intended to be a quick fix for compatibility with openai responses streaming; but Reuben has already provided a stable change (see #1550); closing

@DeagleGross DeagleGross deleted the dmkorolev/openairesponses-evensequence branch October 20, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants