Handle FunctionCallOutputResponseItem in streaming response conversion#7307
Handle FunctionCallOutputResponseItem in streaming response conversion#7307stephentoub merged 5 commits intomainfrom
Conversation
Add a case for FunctionCallOutputResponseItem in the StreamingResponseOutputItemDoneUpdate switch in FromOpenAIStreamingResponseUpdatesAsync, matching the non-streaming ToChatMessage behavior. This ensures streaming responses correctly produce FunctionResultContent instead of falling through to the default generic AIContent case. Fixes #7306 Co-authored-by: stephentoub <[email protected]>
|
@copilot, if the server sends the FunctionCallContent and FunctionResultContent, it's it possible for the chat client to mark the call content as information only so that the client doesn't try to invoke it? |
Yes, |
|
Will handle it in a followup |
There was a problem hiding this comment.
Pull request overview
Aligns the OpenAI Responses streaming conversion path with the existing non-streaming conversion by correctly mapping function_call_output items to FunctionResultContent, preventing consumers from seeing inconsistent content types between GetStreamingResponseAsync and GetResponseAsync.
Changes:
- Add handling for
FunctionCallOutputResponseIteminFromOpenAIStreamingResponseUpdatesAsyncsoresponse.output_item.doneyieldsFunctionResultContent. - Add a unit test that streams a
function_call_outputitem and asserts aFunctionResultContentis produced.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs |
Adds streaming conversion case for FunctionCallOutputResponseItem to yield FunctionResultContent. |
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs |
Adds a streaming test validating function_call_output becomes FunctionResultContent. |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Show resolved
Hide resolved
…put, validate ToChatResponse, use null coalescing for lastRole Co-authored-by: stephentoub <[email protected]>
Head branch was pushed to by a user without write access
FunctionCallOutputResponseItemcase to streaming conversion withlastRole ??= ChatRole.Assistantfunction_callbeforefunction_call_outputToChatResponse()produces single message with FunctionCallContent, FunctionResultContent, and TextContentOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Microsoft Reviewers: Open in CodeFlow