Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public AgentRunOptions(AgentRunOptions options)
/// If the implementation does not support background responses, this property will be ignored.
/// </para>
/// </remarks>
public bool? AllowBackgroundResponses { get; set; }
public bool AllowBackgroundResponses { get; set; }

/// <summary>
/// Gets or sets additional properties associated with these options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ await thread.AIContextProvider.InvokedAsync(new(inputMessages, aiContextProvider
static ChatOptions? ApplyBackgroundResponsesProperties(ChatOptions? chatOptions, AgentRunOptions? agentRunOptions)
{
// If any of the background response properties are set in the run options, we should apply both to the chat options.
if (agentRunOptions?.AllowBackgroundResponses is not null || agentRunOptions?.ContinuationToken is not null)
if (agentRunOptions?.AllowBackgroundResponses == true || agentRunOptions?.ContinuationToken is not null)
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The condition logic doesn't properly handle the case where AllowBackgroundResponses is explicitly set to false in AgentRunOptions.

With the change from bool? to bool, there's no way to distinguish between "not set" (default false) and "explicitly set to false". The current condition agentRunOptions?.AllowBackgroundResponses == true only enters the block when the value is true, meaning that an explicit false value won't be propagated to chatOptions unless ContinuationToken is also set.

This creates an inconsistency: if a user wants to override a true value from ChatOptions by setting AllowBackgroundResponses = false in AgentRunOptions, it will only work if they also provide a ContinuationToken. Without the ContinuationToken, the override won't take effect.

The test RunAsyncPrioritizesBackgroundResponsesPropertiesFromAgentRunOptionsOverOnesFromChatOptionsAsync validates that false should override true, but it only passes because it also sets ContinuationToken.

Consider either: (1) Always apply background response properties when agentRunOptions is not null, or (2) Revert to bool? to maintain the ability to distinguish "not set" from "explicitly false", or (3) Add a separate flag to indicate whether the property was explicitly set.

Copilot uses AI. Check for mistakes.
{
chatOptions ??= new ChatOptions();
chatOptions.AllowBackgroundResponses = agentRunOptions.AllowBackgroundResponses;
Expand Down
Loading