Skip to content

Commit a02d604

Browse files
.Net: Add support for 'minimal' reasoning effort for {Azure}+OpenAI Connectors (#12989)
This PR resolves issue #12887 by adding support for the new 'minimal' reasoning effort level introduced with gpt-5 models. Interestingly enought the latest 2.3.0 version of OpenAI SDK doesn't have a specific `ChatReasoningEffortLevel.Minimal` option, but this is possible using a string "minimal" effort. ## Problem Users were unable to use the new 'minimal' reasoning effort level with GPT-5 and other reasoning models, receiving the error: ``` The provided reasoning effort 'minimal' is not supported. ``` ## Solution The fix adds support for the "minimal" string value in the `GetEffortLevel` method within `ClientCore.ChatCompletion.cs`. The implementation leverages OpenAI SDK implicit string conversion capability for `ChatReasoningEffortLevel` type. ### Changes Made 1. **Updated `GetEffortLevel` method** to recognize "MINIMAL" (case-insensitive) and convert it to `(ChatReasoningEffortLevel)"minimal"` 2. **Added comprehensive test coverage** for the new "minimal" option in both OpenAI and AzureOpenAI connector unit tests 3. **Updated documentation** in `OpenAIPromptExecutionSettings.cs` to include "minimal" as a supported string value ### Usage Users can now specify reasoning effort in multiple ways: ```csharp // Using string (new minimal option) var settings = new OpenAIPromptExecutionSettings { ReasoningEffort = "minimal" }; // Using existing enum values (unchanged) var settings = new OpenAIPromptExecutionSettings { ReasoningEffort = ChatReasoningEffortLevel.Low }; ``` All supported string values: `"low"`, `"medium"`, `"high"`, `"minimal"` ## Testing - ✅ All existing tests continue to pass (471 OpenAI + 490 AzureOpenAI tests) - ✅ New test cases validate "minimal" support in both connectors - ✅ Backward compatibility maintained for existing reasoning effort values - ✅ Invalid strings still throw appropriate `NotSupportedException` Fixes #12887 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/semantic-kernel/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
1 parent 4c55424 commit a02d604

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

dotnet/src/Connectors/Connectors.AzureOpenAI.UnitTests/Services/AzureOpenAIChatCompletionServiceTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ public async Task GetChatMessageContentsRequestHandlesInternalFieldsCorrectlyAsy
421421
[InlineData("string", "low")]
422422
[InlineData("string", "medium")]
423423
[InlineData("string", "high")]
424+
[InlineData("string", "minimal")]
424425
[InlineData("ChatReasonEffortLevel.Low", "low")]
425426
[InlineData("ChatReasonEffortLevel.Medium", "medium")]
426427
[InlineData("ChatReasonEffortLevel.High", "high")]

dotnet/src/Connectors/Connectors.OpenAI.UnitTests/Services/OpenAIChatCompletionServiceTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ public async Task GetChatMessageInResponseFormatsAsync(string formatType, string
10101010
[InlineData("string", "low")]
10111011
[InlineData("string", "medium")]
10121012
[InlineData("string", "high")]
1013+
[InlineData("string", "minimal")]
10131014
[InlineData("ChatReasonEffortLevel.Low", "low")]
10141015
[InlineData("ChatReasonEffortLevel.Medium", "medium")]
10151016
[InlineData("ChatReasonEffortLevel.High", "high")]

dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.ChatCompletion.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ protected virtual ChatCompletionOptions CreateChatCompletionOptions(
557557
"LOW" => ChatReasoningEffortLevel.Low,
558558
"MEDIUM" => ChatReasoningEffortLevel.Medium,
559559
"HIGH" => ChatReasoningEffortLevel.High,
560+
"MINIMAL" => new("minimal"),
560561
_ => throw new NotSupportedException($"The provided reasoning effort '{textEffortLevel}' is not supported.")
561562
};
562563
}

dotnet/src/Connectors/Connectors.OpenAI/Settings/OpenAIPromptExecutionSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class OpenAIPromptExecutionSettings : PromptExecutionSettings
2626
/// Constrains effort on reasoning for reasoning models.
2727
/// Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
2828
/// Possible values are:
29-
/// <para>- <see cref="string"/> values: <c>"low"</c>, <c>"medium"</c>, <c>"high"</c>;</para>
29+
/// <para>- <see cref="string"/> values: <c>"low"</c>, <c>"medium"</c>, <c>"high"</c>, <c>"minimal"</c>;</para>
3030
/// <para>- <see cref="ChatReasoningEffortLevel"/> object;</para>
3131
/// </remarks>
3232
[JsonPropertyName("reasoning_effort")]

0 commit comments

Comments
 (0)