Skip to content

Map ReasoningEffort.None and ExtraHigh to "none" and "xhigh" in OpenAI IChatClient implementations#7319

Merged
stephentoub merged 5 commits intomainfrom
copilot/fix-none-reasoning-mapping
Feb 24, 2026
Merged

Map ReasoningEffort.None and ExtraHigh to "none" and "xhigh" in OpenAI IChatClient implementations#7319
stephentoub merged 5 commits intomainfrom
copilot/fix-none-reasoning-mapping

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

ReasoningEffort.None and ReasoningEffort.ExtraHigh were not mapping to their correct OpenAI API values. None was falling through to the wildcard default and mapping to null (indistinguishable from "not specified"), and ExtraHigh was mapping to High. Since ChatReasoningEffortLevel and ResponseReasoningEffortLevel are string-based extensible enum types, we construct new instances with the appropriate string values for cases where no static property is exposed.

Changes

  • OpenAIChatClient.cs: Map ReasoningEffort.Nonenew ChatReasoningEffortLevel("none"), ReasoningEffort.ExtraHighnew ChatReasoningEffortLevel("xhigh")
  • OpenAIResponsesChatClient.cs: Map ReasoningEffort.Nonenew ResponseReasoningEffortLevel("none"), ReasoningEffort.ExtraHighnew ResponseReasoningEffortLevel("xhigh")
  • Tests: Added None/"none" and ExtraHigh/"xhigh" as [InlineData] on the existing parameterized theory tests
// Before: None fell through to _ => null, ExtraHigh mapped to High
// After:
effort switch
{
    ReasoningEffort.None => new ChatReasoningEffortLevel("none"),
    ReasoningEffort.Low => ChatReasoningEffortLevel.Low,
    ReasoningEffort.Medium => ChatReasoningEffortLevel.Medium,
    ReasoningEffort.High => ChatReasoningEffortLevel.High,
    ReasoningEffort.ExtraHigh => new ChatReasoningEffortLevel("xhigh"),
    _ => (ChatReasoningEffortLevel?)null,
};

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Microsoft Reviewers: Open in CodeFlow

@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Feb 19, 2026
Copilot AI changed the title [WIP] Fix mapping for None reasoning effort in OpenAI ichatclient impls Map ReasoningEffort.None to Minimal in OpenAI IChatClient implementations Feb 19, 2026
Copilot AI requested a review from stephentoub February 19, 2026 15:04
…oningEffortLevel("none") instead of Minimal

Co-authored-by: stephentoub <[email protected]>
Copilot AI changed the title Map ReasoningEffort.None to Minimal in OpenAI IChatClient implementations Map ReasoningEffort.None to "none" in OpenAI IChatClient implementations Feb 19, 2026
Copilot AI requested a review from stephentoub February 19, 2026 15:14
Copilot AI changed the title Map ReasoningEffort.None to "none" in OpenAI IChatClient implementations Map ReasoningEffort.None and ExtraHigh to "none" and "xhigh" in OpenAI IChatClient implementations Feb 19, 2026
@stephentoub stephentoub marked this pull request as ready for review February 19, 2026 19:58
@stephentoub stephentoub requested a review from a team as a code owner February 19, 2026 19:58
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

Updates OpenAI IChatClient implementations in Microsoft.Extensions.AI.OpenAI to correctly translate ReasoningEffort.None and ReasoningEffort.ExtraHigh to OpenAI API-compatible string values, and adjusts unit tests accordingly.

Changes:

  • Map ReasoningEffort.None to "none" (instead of falling through to null) in both chat-completions and responses clients.
  • Map ReasoningEffort.ExtraHigh to "xhigh" (instead of clamping to High) in both clients.
  • Update OpenAI OpenAI test suites to validate the new JSON values via existing theory-based tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs Updates ReasoningEffortChatReasoningEffortLevel mapping for None/ExtraHigh.
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs Updates ReasoningEffortResponseReasoningEffortLevel mapping for None/ExtraHigh.
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIChatClientTests.cs Adjusts theory data to expect "none"/"xhigh" for chat-completions request JSON.
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs Adjusts theory data to expect "none"/"xhigh" for responses request JSON; removes an older fact test.

@stephentoub stephentoub enabled auto-merge (squash) February 19, 2026 22:09
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.

LGTM. Looked for docs to update and couldn't find anything. Test changes make sense.

@stephentoub stephentoub merged commit 2c7c846 into main Feb 24, 2026
11 checks passed
@stephentoub stephentoub deleted the copilot/fix-none-reasoning-mapping branch February 24, 2026 16:57
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.

4 participants