From d98d1b9cf3eb863538c2e4c434a747024453dca0 Mon Sep 17 00:00:00 2001 From: stangorkin Date: Thu, 11 Dec 2025 18:56:07 -0800 Subject: [PATCH 1/2] added toggle for reasoning summary --- data/discord-chat.ndjson | 34 +++++++++++++++++++ .../OpenAIResponseOptionsTransmuter.cs | 16 ++++++--- src/Coven.Agents.OpenAI/ReasoningConfig.cs | 5 +++ .../01.DiscordAgent/DiscordAgent.csproj | 4 +-- src/samples/01.DiscordAgent/Program.cs | 2 +- 5 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 data/discord-chat.ndjson diff --git a/data/discord-chat.ndjson b/data/discord-chat.ndjson new file mode 100644 index 0000000..6f7ae17 --- /dev/null +++ b/data/discord-chat.ndjson @@ -0,0 +1,34 @@ +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatEfferentDraft","text":"Yes\u2014loud and clear! I can see your message and everything\u2019s working. What would you like to do next?","sender":"BOT"}} +{"schemaVersion":"1","position":3,"entry":{"$type":"ChatChunk","text":"Yes\u2014loud and clear! I can see your message and everything\u2019s working. What would you like to do next?","sender":"BOT"}} +{"schemaVersion":"1","position":4,"entry":{"$type":"ChatStreamCompleted","sender":"BOT"}} +{"schemaVersion":"1","position":5,"entry":{"$type":"ChatEfferent","text":"Yes\u2014loud and clear! I can see your message and everything\u2019s working. What would you like to do next?","sender":"BOT"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatEfferentDraft","text":"Yes\u2014it\u0027s working. I can see your message. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":3,"entry":{"$type":"ChatChunk","text":"Yes\u2014it\u0027s working. I can see your message. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":4,"entry":{"$type":"ChatStreamCompleted","sender":"BOT"}} +{"schemaVersion":"1","position":5,"entry":{"$type":"ChatEfferent","text":"Yes\u2014it\u0027s working. I can see your message. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":6,"entry":{"$type":"ChatAck","position":2,"sender":"BOT"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatEfferentDraft","text":"Yes\u2014loud and clear, hunts135. I can see your message and reply here. What would you like to do next?","sender":"BOT"}} +{"schemaVersion":"1","position":3,"entry":{"$type":"ChatChunk","text":"Yes\u2014loud and clear, hunts135. I can see your message and reply here. What would you like to do next?","sender":"BOT"}} +{"schemaVersion":"1","position":4,"entry":{"$type":"ChatStreamCompleted","sender":"BOT"}} +{"schemaVersion":"1","position":5,"entry":{"$type":"ChatEfferent","text":"Yes\u2014loud and clear, hunts135. I can see your message and reply here. What would you like to do next?","sender":"BOT"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatEfferentDraft","text":"Yes\u2014your message came through. I can see you, hunts135. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":3,"entry":{"$type":"ChatChunk","text":"Yes\u2014your message came through. I can see you, hunts135. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":4,"entry":{"$type":"ChatStreamCompleted","sender":"BOT"}} +{"schemaVersion":"1","position":5,"entry":{"$type":"ChatEfferent","text":"Yes\u2014your message came through. I can see you, hunts135. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":6,"entry":{"$type":"ChatAck","position":2,"sender":"BOT"}} diff --git a/src/Coven.Agents.OpenAI/OpenAIResponseOptionsTransmuter.cs b/src/Coven.Agents.OpenAI/OpenAIResponseOptionsTransmuter.cs index a295dff..f82d4a2 100644 --- a/src/Coven.Agents.OpenAI/OpenAIResponseOptionsTransmuter.cs +++ b/src/Coven.Agents.OpenAI/OpenAIResponseOptionsTransmuter.cs @@ -21,7 +21,7 @@ public Task Transmute(OpenAIClientConfig Input, Cancell if (Input.Reasoning is not null) { - options.ReasoningOptions = new ResponseReasoningOptions() + ResponseReasoningOptions reasoning = new() { ReasoningEffortLevel = Input.Reasoning.Effort switch { @@ -29,15 +29,21 @@ public Task Transmute(OpenAIClientConfig Input, Cancell ReasoningEffort.Medium => ResponseReasoningEffortLevel.Medium, ReasoningEffort.High => ResponseReasoningEffortLevel.High, _ => null - }, - ReasoningSummaryVerbosity = Input.Reasoning.SummaryVerbosity switch + } + }; + + if (Input.Reasoning.IncludeSummary) + { + reasoning.ReasoningSummaryVerbosity = Input.Reasoning.SummaryVerbosity switch { ReasoningSummaryVerbosity.Auto => ResponseReasoningSummaryVerbosity.Auto, ReasoningSummaryVerbosity.Detailed => ResponseReasoningSummaryVerbosity.Detailed, ReasoningSummaryVerbosity.Concise => ResponseReasoningSummaryVerbosity.Concise, _ => null - } - }; + }; + } + + options.ReasoningOptions = reasoning; } return Task.FromResult(options); diff --git a/src/Coven.Agents.OpenAI/ReasoningConfig.cs b/src/Coven.Agents.OpenAI/ReasoningConfig.cs index 190a4a9..72dc565 100644 --- a/src/Coven.Agents.OpenAI/ReasoningConfig.cs +++ b/src/Coven.Agents.OpenAI/ReasoningConfig.cs @@ -16,4 +16,9 @@ public sealed class ReasoningConfig /// Controls verbosity of returned reasoning summaries. /// public ReasoningSummaryVerbosity SummaryVerbosity { get; init; } = ReasoningSummaryVerbosity.Auto; + + /// + /// Whether to request reasoning summaries. Defaults to false. + /// + public bool IncludeSummary { get; init; } } diff --git a/src/samples/01.DiscordAgent/DiscordAgent.csproj b/src/samples/01.DiscordAgent/DiscordAgent.csproj index 304d2f2..404eee5 100644 --- a/src/samples/01.DiscordAgent/DiscordAgent.csproj +++ b/src/samples/01.DiscordAgent/DiscordAgent.csproj @@ -26,8 +26,8 @@ - - + + diff --git a/src/samples/01.DiscordAgent/Program.cs b/src/samples/01.DiscordAgent/Program.cs index 1937321..9a292c0 100644 --- a/src/samples/01.DiscordAgent/Program.cs +++ b/src/samples/01.DiscordAgent/Program.cs @@ -62,7 +62,7 @@ builder.Services.AddDiscordChat(discordConfig); builder.Services.AddOpenAIAgents(openAiConfig, registration => { - registration.EnableStreaming(); + // registration.EnableStreaming(); }); // Override windowing policies independently for outputs and thoughts From d6a219673cd949422d49112ed10c6dddf44cd02d Mon Sep 17 00:00:00 2001 From: stangorkin Date: Fri, 12 Dec 2025 21:45:32 -0800 Subject: [PATCH 2/2] Hopefully addressed PR comments --- .gitignore | 4 ++++ data/discord-chat.ndjson | 12 ++++++++++++ src/Coven.Agents.OpenAI/OpenAIClientConfig.cs | 8 ++++---- src/samples/01.DiscordAgent/DiscordAgent.csproj | 4 ---- src/samples/01.DiscordAgent/Program.cs | 10 ++++++++-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 009742c..79781ad 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,7 @@ scratch.txt # Codex CLI generated state **/.codex/ + +src/samples/01.DiscordAgent/Properties/ +data/discord-chat.ndjson + diff --git a/data/discord-chat.ndjson b/data/discord-chat.ndjson index 6f7ae17..57a6197 100644 --- a/data/discord-chat.ndjson +++ b/data/discord-chat.ndjson @@ -32,3 +32,15 @@ {"schemaVersion":"1","position":4,"entry":{"$type":"ChatStreamCompleted","sender":"BOT"}} {"schemaVersion":"1","position":5,"entry":{"$type":"ChatEfferent","text":"Yes\u2014your message came through. I can see you, hunts135. How can I help?","sender":"BOT"}} {"schemaVersion":"1","position":6,"entry":{"$type":"ChatAck","position":2,"sender":"BOT"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatEfferentDraft","text":"Yes\u2014got your message, hunts135. I\u2019m here and responsive. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":3,"entry":{"$type":"ChatChunk","text":"Yes\u2014got your message, hunts135. I\u2019m here and responsive. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":4,"entry":{"$type":"ChatStreamCompleted","sender":"BOT"}} +{"schemaVersion":"1","position":5,"entry":{"$type":"ChatEfferent","text":"Yes\u2014got your message, hunts135. I\u2019m here and responsive. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":6,"entry":{"$type":"ChatAck","position":2,"sender":"BOT"}} +{"schemaVersion":"1","position":1,"entry":{"$type":"ChatAfferent","text":"Is this working?","sender":"hunts135"}} +{"schemaVersion":"1","position":2,"entry":{"$type":"ChatEfferentDraft","text":"Yes\u2014I can see your message, hunts135. Looks like everything\u2019s working. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":3,"entry":{"$type":"ChatChunk","text":"Yes\u2014I can see your message, hunts135. Looks like everything\u2019s working. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":4,"entry":{"$type":"ChatStreamCompleted","sender":"BOT"}} +{"schemaVersion":"1","position":5,"entry":{"$type":"ChatEfferent","text":"Yes\u2014I can see your message, hunts135. Looks like everything\u2019s working. How can I help?","sender":"BOT"}} +{"schemaVersion":"1","position":6,"entry":{"$type":"ChatAck","position":2,"sender":"BOT"}} diff --git a/src/Coven.Agents.OpenAI/OpenAIClientConfig.cs b/src/Coven.Agents.OpenAI/OpenAIClientConfig.cs index 81bfd6e..ed27bba 100644 --- a/src/Coven.Agents.OpenAI/OpenAIClientConfig.cs +++ b/src/Coven.Agents.OpenAI/OpenAIClientConfig.cs @@ -43,12 +43,12 @@ public sealed record OpenAIClientConfig public int? MaxOutputTokens { get; init; } /// - /// Max number of transcript items to include; defaults to unlimited. + /// Configures reasoning options for models that support it. /// - public int HistoryClip { get; init; } = int.MaxValue; + public ReasoningConfig? Reasoning { get; init; } /// - /// Configures reasoning options for models that support it. + /// Max number of transcript items to include; defaults to unlimited. /// - public ReasoningConfig Reasoning { get; init; } = new ReasoningConfig(); + public int HistoryClip { get; init; } = int.MaxValue; } diff --git a/src/samples/01.DiscordAgent/DiscordAgent.csproj b/src/samples/01.DiscordAgent/DiscordAgent.csproj index 404eee5..00fc786 100644 --- a/src/samples/01.DiscordAgent/DiscordAgent.csproj +++ b/src/samples/01.DiscordAgent/DiscordAgent.csproj @@ -26,8 +26,4 @@ - - - - diff --git a/src/samples/01.DiscordAgent/Program.cs b/src/samples/01.DiscordAgent/Program.cs index 9a292c0..235b320 100644 --- a/src/samples/01.DiscordAgent/Program.cs +++ b/src/samples/01.DiscordAgent/Program.cs @@ -43,7 +43,13 @@ OpenAIClientConfig openAiConfig = new() { ApiKey = string.IsNullOrWhiteSpace(envOpenAiApiKey) ? defaultOpenAiApiKey : envOpenAiApiKey, - Model = string.IsNullOrWhiteSpace(envOpenAiModel) ? defaultOpenAiModel : envOpenAiModel + Model = string.IsNullOrWhiteSpace(envOpenAiModel) ? defaultOpenAiModel : envOpenAiModel, + Reasoning = new ReasoningConfig + { + Effort = ReasoningEffort.High, // or Medium/Low + IncludeSummary = true, // optional; default false + SummaryVerbosity = ReasoningSummaryVerbosity.Detailed + } }; // Register DI @@ -62,7 +68,7 @@ builder.Services.AddDiscordChat(discordConfig); builder.Services.AddOpenAIAgents(openAiConfig, registration => { - // registration.EnableStreaming(); + registration.EnableStreaming(); }); // Override windowing policies independently for outputs and thoughts