You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.NET: Setting ReasoningEffort on an agent is cumbersome #1455
When you need to create an agent that use reasoning effort (example: GPT-5) you need to do it in the following way
ChatClientAgentagent=chatClient.CreateAIAgent(options:newChatClientAgentOptions{Instructions="You are a nice AI",ChatOptions=newChatOptions{RawRepresentationFactory= _ =>newChatCompletionOptions{
#pragma warning disable OPENAI001ReasoningEffortLevel="minimal",
#pragma warning restore OPENAI001},Tools=[]//Tools goes here}});
While this works, it is quite a cumbersome approach for configuring such an important setting (since GPT-5 but default use 'medium' reasoning which in not suited for quick and cheap answers you very often need to lower the default)
I would be so nice if we could do something like this instead:
ChatClientAgentagent=chatClient.CreateAIAgent(instructions:"You are a nice AI",tools:[],//Tools goes herereasoningEffort="minimal");
I do understand that not every LLM out there understand reasoningEffort, but same could be said for tools
Is there any plans to expose Reasoning Effort in a less cumbersome manner?
Even for providers that expose the ability to control reasoning, they often do it in different ways. Anthropic and Google, for example, both do so by the developer specifying a token budget, exactly how many tokens should be allowed for reasoning. What does "minimal" mean there? We'd have to own an opinionated mapping, and that's not something we've yet been comfortable doing, in particular around something that is directly tied to cost.
So while we certainly might add an easier knob in the future, there's no current "plan" to do so.
With the new extension properties it's trivial and very intuitive to do so:
using System.ComponentModel;
using Microsoft.Extensions.AI;
namespace Devlooped.Extensions.AI;
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ChatExtensions
{
extension(ChatOptions options)
{
/// <summary>
/// Sets the effort level for a reasoning AI model when generating responses, if supported
/// by the model.
/// </summary>
public ReasoningEffort? ReasoningEffort
{
get => options.AdditionalProperties?.TryGetValue("reasoning_effort", out var value) == true && value is ReasoningEffort effort ? effort : null;
set
{
if (value is not null)
{
options.AdditionalProperties ??= [];
options.AdditionalProperties["reasoning_effort"] = value;
}
else
{
options.AdditionalProperties?.Remove("reasoning_effort");
}
}
}
/// <summary>
/// Sets the <see cref="Verbosity"/> level for a GPT-5 model when generating responses, if supported
/// </summary>
public Verbosity? Verbosity
{
get => options.AdditionalProperties?.TryGetValue("verbosity", out var value) == true && value is Verbosity verbosity ? verbosity : null;
set
{
if (value is not null)
{
options.AdditionalProperties ??= [];
options.AdditionalProperties["verbosity"] = value;
}
else
{
options.AdditionalProperties?.Remove("verbosity");
}
}
}
}
}
Activity
stephentoub commentedon Oct 14, 2025
Even for providers that expose the ability to control reasoning, they often do it in different ways. Anthropic and Google, for example, both do so by the developer specifying a token budget, exactly how many tokens should be allowed for reasoning. What does "minimal" mean there? We'd have to own an opinionated mapping, and that's not something we've yet been comfortable doing, in particular around something that is directly tied to cost.
So while we certainly might add an easier knob in the future, there's no current "plan" to do so.
rwjdk-test commentedon Oct 14, 2025
Stephen Toub (@stephentoub) : Thanks for info:
Will make my own opinionated Extension Method to abstract away the complexity until a future point in time 👍 (Not a big deal to do so)
kzu commentedon Oct 14, 2025
With the new extension properties it's trivial and very intuitive to do so:
This is from https://github.com/devlooped/AI?tab=readme-ov-file#openai
Add support for setting reasoning effort and verbosity via config
Add support for setting reasoning effort and verbosity via config
Add support for setting reasoning effort and verbosity via config
rogerbarreto commentedon Oct 16, 2025
This issue is related to abstractions in Microsoft.Extensions.AI.
Closing this issue as not planned for now similar as in the tickets below:
IChatClientChatOptions- support new properties viaAdditionalPropertiesOR addReasoningEffortproperty? dotnet/extensions#6531