Skip to content

.NET: Setting ReasoningEffort on an agent is cumbersome #1455

Closed as not planned

Description

When you need to create an agent that use reasoning effort (example: GPT-5) you need to do it in the following way

ChatClientAgent agent = chatClient.CreateAIAgent(
    options: new ChatClientAgentOptions
    {
        Instructions = "You are a nice AI",
        ChatOptions = new ChatOptions
        {
            RawRepresentationFactory = _ => new ChatCompletionOptions
            {
#pragma warning disable OPENAI001
                ReasoningEffortLevel = "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:

ChatClientAgent agent = chatClient.CreateAIAgent(
    instructions: "You are a nice AI",
    tools: [], //Tools goes here
    reasoningEffort = "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?

Activity

  1. added
    .NETUsage: [Issues, PRs], Target: .Net
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 14, 2025
  2. stephentoub commented on Oct 14, 2025

    @stephentoub
    Member

    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.

  3. rwjdk-test commented on Oct 14, 2025

    @rwjdk-test
    Author

    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)

  4. kzu commented on Oct 14, 2025

    @kzu
    Contributor

    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");
                    }
                }
            }
        }
    }
    

    This is from https://github.com/devlooped/AI?tab=readme-ov-file#openai

  5. added
    agentsUsage: [Issues, PRs], Target: Single agent
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 15, 2025
  6. rogerbarreto commented on Oct 16, 2025

    @rogerbarreto
    Member

    This issue is related to abstractions in Microsoft.Extensions.AI.

    Closing this issue as not planned for now similar as in the tickets below:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .NetagentsUsage: [Issues, PRs], Target: Single agent

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions