From 41a3e1d9bf13e6f2cf41a5f77ed2ec3f588931ed Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 31 Oct 2025 08:33:30 -0400 Subject: [PATCH 1/5] OpenAI-DotNet 8.8.4 - Fix RealtimeSessionConfiguration and CreateResponseRequest model parameter overriding prompt settings. --- OpenAI-DotNet/OpenAI-DotNet.csproj | 4 +- .../Realtime/SessionConfiguration.cs | 92 ++++++++++++++----- .../Responses/CreateResponseRequest.cs | 5 +- 3 files changed, 74 insertions(+), 27 deletions(-) diff --git a/OpenAI-DotNet/OpenAI-DotNet.csproj b/OpenAI-DotNet/OpenAI-DotNet.csproj index 2e81ad85..a7069cba 100644 --- a/OpenAI-DotNet/OpenAI-DotNet.csproj +++ b/OpenAI-DotNet/OpenAI-DotNet.csproj @@ -29,8 +29,10 @@ More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet- OpenAI-DotNet.pfx true true - 8.8.3 + 8.8.4 +Version 8.8.4 +- Fix RealtimeSessionConfiguration and CreateResponseRequest model parameter overriding prompt settings. Version 8.8.3 - Fix regression ObjectDisposedException from OpenAIBaseEndpoint refactoring - Add Azure Blob Batch API compatible fields for CreateBatchRequest diff --git a/OpenAI-DotNet/Realtime/SessionConfiguration.cs b/OpenAI-DotNet/Realtime/SessionConfiguration.cs index d6f4eaa6..93e75943 100644 --- a/OpenAI-DotNet/Realtime/SessionConfiguration.cs +++ b/OpenAI-DotNet/Realtime/SessionConfiguration.cs @@ -27,44 +27,85 @@ public SessionConfiguration( string toolChoice, float? temperature, int? maxResponseOutputTokens, - int? expiresAfter) - : this( - model: model, - modalities: modalities, - voice: voice, - instructions: instructions, - inputAudioFormat: inputAudioFormat, - outputAudioFormat: outputAudioFormat, - inputAudioTranscriptionSettings: new(transcriptionModel), - turnDetectionSettings: turnDetectionSettings, - tools: tools, - toolChoice: toolChoice, - temperature: temperature, - maxResponseOutputTokens: maxResponseOutputTokens, - expiresAfter: expiresAfter) + int? expiresAfter) : this( + model, + prompt: null, + instructions, + modalities, + voice, + speed: null, + inputAudioFormat, + outputAudioFormat, + inputAudioNoiseSettings: null, + inputAudioTranscriptionSettings: new(transcriptionModel), + turnDetectionSettings, + tools, + toolChoice, + temperature, + maxResponseOutputTokens, + expiresAfter) { } + [Obsolete("Use new ctor overload")] public SessionConfiguration( Model model, + Modality modalities, + Voice voice, + string instructions, + RealtimeAudioFormat inputAudioFormat, + RealtimeAudioFormat outputAudioFormat, + InputAudioTranscriptionSettings inputAudioTranscriptionSettings, + IVoiceActivityDetectionSettings turnDetectionSettings, + IEnumerable tools, + string toolChoice, + float? temperature, + int? maxResponseOutputTokens, + int? expiresAfter, + NoiseReductionSettings inputAudioNoiseSettings, + float? speed, + Prompt prompt) : this( + model, + prompt, + instructions, + modalities, + voice, + speed, + inputAudioFormat, + outputAudioFormat, + inputAudioNoiseSettings, + inputAudioTranscriptionSettings, + turnDetectionSettings, + tools, + toolChoice, + temperature, + maxResponseOutputTokens, + expiresAfter) + { + } + + public SessionConfiguration( + Model model = null, + Prompt prompt = null, + string instructions = null, Modality modalities = Modality.Text | Modality.Audio, Voice voice = null, - string instructions = null, + float? speed = null, RealtimeAudioFormat inputAudioFormat = RealtimeAudioFormat.PCM16, RealtimeAudioFormat outputAudioFormat = RealtimeAudioFormat.PCM16, + NoiseReductionSettings inputAudioNoiseSettings = null, InputAudioTranscriptionSettings inputAudioTranscriptionSettings = null, IVoiceActivityDetectionSettings turnDetectionSettings = null, IEnumerable tools = null, string toolChoice = null, float? temperature = null, int? maxResponseOutputTokens = null, - int? expiresAfter = null, - NoiseReductionSettings inputAudioNoiseSettings = null, - float? speed = null, - Prompt prompt = null) + int? expiresAfter = null) { ClientSecret = new ClientSecret(expiresAfter); - Model = string.IsNullOrWhiteSpace(model?.Id) ? Models.Model.GPT4oRealtime : model; + Model = string.IsNullOrWhiteSpace(model?.Id) && prompt == null + ? Models.Model.GPT4oRealtime + : model; Modalities = modalities; Voice = string.IsNullOrWhiteSpace(voice?.Id) ? OpenAI.Voice.Alloy : voice; Instructions = string.IsNullOrWhiteSpace(instructions) @@ -82,10 +123,10 @@ public SessionConfiguration( VoiceActivityDetectionSettings = turnDetectionSettings ?? new ServerVAD(); tools.ProcessTools(toolChoice, out var toolList, out var activeTool); Tools = toolList?.Where(t => t.IsFunction).Select(tool => - { - tool.Function.Type = "function"; - return tool.Function; - }).ToList(); + { + tool.Function.Type = "function"; + return tool.Function; + }).ToList(); ToolChoice = activeTool; Temperature = temperature; @@ -153,6 +194,7 @@ internal SessionConfiguration( /// [JsonInclude] [JsonPropertyName("model")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string Model { get; private set; } /// diff --git a/OpenAI-DotNet/Responses/CreateResponseRequest.cs b/OpenAI-DotNet/Responses/CreateResponseRequest.cs index b314ba77..65bf0abb 100644 --- a/OpenAI-DotNet/Responses/CreateResponseRequest.cs +++ b/OpenAI-DotNet/Responses/CreateResponseRequest.cs @@ -159,7 +159,9 @@ public CreateResponseRequest( int? topLogProbs = null) { Input = input?.ToArray() ?? throw new ArgumentNullException(nameof(input)); - Model = string.IsNullOrWhiteSpace(model) ? Models.Model.ChatGPT4o : model; + Model = string.IsNullOrWhiteSpace(model?.Id) && prompt == null + ? Models.Model.GPT4oRealtime + : model; Background = background; Include = include?.ToList(); Instructions = instructions; @@ -214,6 +216,7 @@ public CreateResponseRequest( /// [JsonInclude] [JsonPropertyName("model")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string Model { get; private set; } /// From 38ef6657eef6ff577d3e3f753f80ece68d985504 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 31 Oct 2025 08:41:07 -0400 Subject: [PATCH 2/5] formatting --- .../Realtime/SessionConfiguration.cs | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/OpenAI-DotNet/Realtime/SessionConfiguration.cs b/OpenAI-DotNet/Realtime/SessionConfiguration.cs index 93e75943..707518c5 100644 --- a/OpenAI-DotNet/Realtime/SessionConfiguration.cs +++ b/OpenAI-DotNet/Realtime/SessionConfiguration.cs @@ -27,23 +27,24 @@ public SessionConfiguration( string toolChoice, float? temperature, int? maxResponseOutputTokens, - int? expiresAfter) : this( - model, - prompt: null, - instructions, - modalities, - voice, - speed: null, - inputAudioFormat, - outputAudioFormat, - inputAudioNoiseSettings: null, - inputAudioTranscriptionSettings: new(transcriptionModel), - turnDetectionSettings, - tools, - toolChoice, - temperature, - maxResponseOutputTokens, - expiresAfter) + int? expiresAfter) + : this( + model, + prompt: null, + instructions, + modalities, + voice, + speed: null, + inputAudioFormat, + outputAudioFormat, + inputAudioNoiseSettings: null, + inputAudioTranscriptionSettings: new(transcriptionModel), + turnDetectionSettings, + tools, + toolChoice, + temperature, + maxResponseOutputTokens, + expiresAfter) { } @@ -64,23 +65,24 @@ public SessionConfiguration( int? expiresAfter, NoiseReductionSettings inputAudioNoiseSettings, float? speed, - Prompt prompt) : this( - model, - prompt, - instructions, - modalities, - voice, - speed, - inputAudioFormat, - outputAudioFormat, - inputAudioNoiseSettings, - inputAudioTranscriptionSettings, - turnDetectionSettings, - tools, - toolChoice, - temperature, - maxResponseOutputTokens, - expiresAfter) + Prompt prompt) + : this( + model, + prompt, + instructions, + modalities, + voice, + speed, + inputAudioFormat, + outputAudioFormat, + inputAudioNoiseSettings, + inputAudioTranscriptionSettings, + turnDetectionSettings, + tools, + toolChoice, + temperature, + maxResponseOutputTokens, + expiresAfter) { } From bdaacb4fe2f265b1d12e3e6af72bafd0866973b2 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 31 Oct 2025 08:41:43 -0400 Subject: [PATCH 3/5] whitespace --- OpenAI-DotNet/Realtime/SessionConfiguration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenAI-DotNet/Realtime/SessionConfiguration.cs b/OpenAI-DotNet/Realtime/SessionConfiguration.cs index 707518c5..3e76bb53 100644 --- a/OpenAI-DotNet/Realtime/SessionConfiguration.cs +++ b/OpenAI-DotNet/Realtime/SessionConfiguration.cs @@ -125,10 +125,10 @@ public SessionConfiguration( VoiceActivityDetectionSettings = turnDetectionSettings ?? new ServerVAD(); tools.ProcessTools(toolChoice, out var toolList, out var activeTool); Tools = toolList?.Where(t => t.IsFunction).Select(tool => - { - tool.Function.Type = "function"; - return tool.Function; - }).ToList(); + { + tool.Function.Type = "function"; + return tool.Function; + }).ToList(); ToolChoice = activeTool; Temperature = temperature; From 7c95c0ab011a5ef8a6328bea9e7ec66ec97af114 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Sun, 2 Nov 2025 23:29:33 -0500 Subject: [PATCH 4/5] lol y not --- OpenAI-DotNet/Extensions/ResponseExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenAI-DotNet/Extensions/ResponseExtensions.cs b/OpenAI-DotNet/Extensions/ResponseExtensions.cs index 4cd48f09..e468f7a9 100644 --- a/OpenAI-DotNet/Extensions/ResponseExtensions.cs +++ b/OpenAI-DotNet/Extensions/ResponseExtensions.cs @@ -256,7 +256,7 @@ private static async Task ReadAsStringAsync(this HttpResponseMessage res if (@event.Data != null) { - @object[ServerSentEventKind.Data.ToString().ToLower()] = JsonNode.Parse(@event.Data.ToJsonString()); + @object[nameof(ServerSentEventKind.Data).ToLower()] = JsonNode.Parse(@event.Data.ToJsonString()); } array.Add(@object); From 3b2262010f27bc7a6a635a2f8bf4f6cb54fd62be Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Mon, 3 Nov 2025 12:56:21 -0500 Subject: [PATCH 5/5] - Fix Threads.MessageResponse.Status not being properly set to Completed --- OpenAI-DotNet/OpenAI-DotNet.csproj | 3 ++- OpenAI-DotNet/Threads/MessageResponse.cs | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenAI-DotNet/OpenAI-DotNet.csproj b/OpenAI-DotNet/OpenAI-DotNet.csproj index a7069cba..235e3f0e 100644 --- a/OpenAI-DotNet/OpenAI-DotNet.csproj +++ b/OpenAI-DotNet/OpenAI-DotNet.csproj @@ -32,7 +32,8 @@ More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet- 8.8.4 Version 8.8.4 -- Fix RealtimeSessionConfiguration and CreateResponseRequest model parameter overriding prompt settings. +- Fix RealtimeSessionConfiguration and CreateResponseRequest model parameter overriding prompt settings +- Fix Threads.MessageResponse.Status not being properly set to Completed Version 8.8.3 - Fix regression ObjectDisposedException from OpenAIBaseEndpoint refactoring - Add Azure Blob Batch API compatible fields for CreateBatchRequest diff --git a/OpenAI-DotNet/Threads/MessageResponse.cs b/OpenAI-DotNet/Threads/MessageResponse.cs index bd23673e..c1f4b13c 100644 --- a/OpenAI-DotNet/Threads/MessageResponse.cs +++ b/OpenAI-DotNet/Threads/MessageResponse.cs @@ -255,8 +255,7 @@ internal void AppendFrom(MessageResponse other) IncompleteAtUnixTimeSeconds = other.IncompleteAtUnixTimeSeconds; } - if (Status == 0 && - other.Status > 0) + if (other.Status > 0) { Status = other.Status; }