Skip to content

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Dec 11, 2025

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested review from a team as code owners December 11, 2025 22:55
Copilot AI review requested due to automatic review settings December 11, 2025 22:55
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Dec 11, 2025
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

This PR updates the OpenAI package dependency from version 2.7.0 to 2.8.0 and adapts the codebase to accommodate breaking changes in OpenAI's Responses API. The update involves significant type and method renames, changes to how conversation IDs are represented, and adjustments to API behavior around tool choices and default values.

Key Changes

  • API Type Renames: Updated all references from OpenAIResponseClient to ResponsesClient, ResponseCreationOptions to CreateResponseOptions, and OpenAIResponse to ResponseResult throughout the codebase
  • Conversation ID Handling: Changed from passing conversation IDs as simple strings to wrapping them in ConversationOptions objects, with a new helper method to identify conversation IDs by their "conv_" prefix
  • API Configuration Changes: Updated the "strictJsonSchema" key to "strict" in AdditionalProperties, removed explicit "tool_choice" settings (now handled as API defaults), and changed the default for ParallelToolCallsEnabled from false to true

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
eng/packages/General.props Updated OpenAI package version from 2.7.0 to 2.8.0
src/Libraries/Microsoft.Extensions.AI.OpenAI/CHANGELOG.md Documented the OpenAI 2.8.0 update and API signature changes
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs Updated type references, changed strict key constant, added IsConversationId helper
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs Major refactoring to use new API types, conversation options, updated tool construction, added Debug.Assert for reflection calls
src/Libraries/Microsoft.Extensions.AI.OpenAI/ResponsesClientContinuationToken.cs Renamed class from OpenAIResponsesContinuationToken to ResponsesClientContinuationToken
src/Libraries/Microsoft.Extensions.AI.OpenAI/MicrosoftExtensionsAIResponsesExtensions.cs Updated method signatures and type references, changed AsOpenAIResponse to AsOpenAIResponseResult
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs Updated all test type references, removed unused JsonNode import, updated test JSON payloads for conversation object structure
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs Updated GetOpenAIResponseClient to GetResponsesClient call
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs Updated type references, test assertions for new defaults, method name changes
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIChatClientTests.cs Updated strict key in test from "strictJsonSchema" to "strict"
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/IntegrationTestHelpers.cs Changed to read API key and mode from environment variables instead of configuration
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs Updated strict key usage in integration tests
src/ProjectTemplates/.../Program.cs Updated template code to use GetResponsesClient instead of GetOpenAIResponseClient
test/ProjectTemplates/.../Snapshots/.../Program.cs Updated test snapshot to match template changes
Comments suppressed due to low confidence (1)

test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/IntegrationTestHelpers.cs:26

  • The IntegrationTestHelpers now reads API key and mode from environment variables but still reads the endpoint from TestRunnerConfiguration. This creates an inconsistency in configuration sources. Either all three values should come from environment variables, or all should come from configuration.

Consider updating line 25 to also use environment variables:
var endpoint = Environment.GetEnvironmentVariable("AI:OpenAI:Endpoint")

        string? apiKey = Environment.GetEnvironmentVariable("AI:OpenAI:ApiKey");
        string? mode = Environment.GetEnvironmentVariable("AI:OpenAI:Mode");

        if (string.Equals(mode, "AzureOpenAI", StringComparison.OrdinalIgnoreCase))
        {
            var endpoint = configuration["OpenAI:Endpoint"]
                ?? throw new InvalidOperationException("To use AzureOpenAI, set a value for OpenAI:Endpoint");

Copy link
Member

@ericstj ericstj left a comment

Choose a reason for hiding this comment

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

A lot of churn, but most looks reasonable. Just a couple suggestions.

@stephentoub stephentoub enabled auto-merge (squash) December 12, 2025 05:12
@stephentoub stephentoub merged commit cc328a7 into dotnet:main Dec 12, 2025
6 checks passed
stephentoub added a commit to ericstj/extensions that referenced this pull request Dec 12, 2025
* Update to OpenAI 2.8.0

* Fix merge and address feedback
@stephentoub stephentoub deleted the openai280 branch December 12, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants