Skip to content

.NET: [Bug]: ChatClientAgent chat options merging omits Reasoning property #5460

@MaciejWarchalowski

Description

@MaciejWarchalowski

Description

Summary

When ChatClientAgent merges per-request ChatOptions with the agent-level ChatOptions, the Reasoning property is not included in the merge. This means that any ReasoningOptions configured on the agent (e.g. Effort, Output) are silently dropped whenever a caller also supplies their own ChatOptions.

Affected file

src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs — the MergeChatOptions block starting around line 545.

Root cause

The merge block applies all nullable ChatOptions properties using ??=, but Reasoning was missing from the list:

// before fix — Reasoning absent
requestChatOptions.PresencePenalty ??= this._agentOptions.ChatOptions.PresencePenalty;
requestChatOptions.ResponseFormat  ??= this._agentOptions.ChatOptions.ResponseFormat;
// Reasoning skipped here
requestChatOptions.Seed            ??= this._agentOptions.ChatOptions.Seed;

Code Sample

Create an agent with follow ChatClientAgentOptions:

        var agentOptions = new ChatClientAgentOptions
        {
            ChatOptions = new ChatOptions
            {
                Reasoning = new ReasoningOptions
                {
                    Effort = ReasoningEffort.ExtraHigh,
                    Output = ReasoningOutput.Full
                }
            }
        };

Then invoke the agent while also supplying a per-request ChatOptions object. The Reasoning values from agentOptions will not be applied to the request.

        var runOptions = new ChatClientAgentRunOptions
        {
            ChatOptions = new ChatOptions
            {
                Instructions = "test"
            }
        };

Error Messages / Stack Traces

Package Versions

Microsoft.Agents.AI v1.0.0

.NET Version

.NET 10

Additional Context

Fix

Add the missing line in the merge block:

requestChatOptions.Reasoning ??= this._agentOptions.ChatOptions.Reasoning;

Impact

Any agent configured with reasoning-capable models that also receives per-request ChatOptions will silently lose its reasoning configuration. The regression is behaviorally silent — no exception is thrown — making it easy to miss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions