semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: Agent constructors should only take required parameters

Open markwallace-microsoft opened this issue 9 months ago • 0 comments

We have code like this

    public OpenAIAssistantAgent(
        Assistant definition,
        AssistantClient client,
        IEnumerable<KernelPlugin>? plugins = null,
        IPromptTemplateFactory? templateFactory = null,
        string? templateFormat = null)

The problem is that using this pattern if we want to set something additional we have to create a new constructor. The pattern we favour is to use init parameters for optional values. So the caller would do something like this:

var OpenAIAssistantAgent = new(definition, client)
{
    Plugins = myPlugins
};

markwallace-microsoft avatar May 21 '25 13:05 markwallace-microsoft