ReasoningModelChatClient<T>

Models & Types · AiDotNet.Agentic.Models.Connectors

Wraps any IChatClient and removes the per-request settings a reasoning model rejects, reporting each removal instead of dropping it in silence.

Implements: IChatClient<T>

For Beginners

Some newer AI models refuse settings such as “creativity” (temperature). If your code sets one and you point it at such a model, the provider rejects the whole request. Wrap your client in this one — new ReasoningModelChatClient<double>(myClient) — and the offending settings are taken out automatically, with a note telling you which ones. Streaming, tools, and everything else pass straight through.

How It Works

Reasoning models — the OpenAI o-series and GPT-5 families and the GPT-OSS releases — answer a request carrying temperature or top_p with an HTTP 400. Any pipeline that sets a temperature, which an evolutionary search normally does, therefore fails on its very first call the moment the model id is switched to one of those. This decorator sits in front of whichever connector you already use, resolves the model id against a ReasoningModelProfileRegistry, and hands the connector a copy of the options with the rejected settings cleared. The caller’s own ChatOptions instance is never mutated.

It deliberately does one thing. Renaming the answer-length cap to max_completion_tokens and attaching reasoning_effort are wire-format concerns that only the connector can carry out, so for OpenAI-shaped endpoints use ReasoningOpenAIChatClient, which does the whole job including the removals this decorator performs. Reach for this decorator when the backend is something else — Azure through a custom connector, a local proxy, a third-party gateway — and you only need the request to stop being rejected.

Every removal is recorded. GetDiagnosticSummary returns one entry per distinct adjustment with a count, and a DiagnosticSink on the options receives every occurrence. That is the difference from the reference implementation, which builds a different parameter dictionary for reasoning models and leaves no trace that the configured temperature never applied.

Constructors

Constructor Summary
ReasoningModelChatClient(IChatClient<T> inner, ReasoningModelOptions options) Initializes a reasoning-aware decorator over an existing chat client.

Properties

Property Summary
IChatClient<T> InnerClient { get; } Gets the wrapped client this decorator delegates to.
ReasoningModelProfile Profile { get; } Gets the profile matching the wrapped client’s model, or null when it is an ordinary model.
string ModelId { get; }

Methods

Method Summary
ChatOptions AdaptOptions(ChatOptions options) Returns the options the wrapped client would be given for a request.
IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IReadOnlyList<ChatMessage> messages, ChatOptions options, CancellationToken cancellationToken)
IReadOnlyDictionary<string, ReasoningModelDiagnosticSummary> GetDiagnosticSummary() Gets one entry per distinct adjustment made so far, with how often it occurred.
ReasoningModelOptions GetOptions() Gets a copy of the reasoning settings in force.
Task<ChatResponse> GetResponseAsync(IReadOnlyList<ChatMessage> messages, ChatOptions options, CancellationToken cancellationToken)