Skip to content

.Net: Agent constructors should only take required parameters #12216

Open
@markwallace-microsoft

Description

@markwallace-microsoft

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codeagents

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions