Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net Agents - Align with expectations when arguments override specified. #9096

Merged
merged 10 commits into from
Oct 4, 2024

Conversation

crickman
Copy link
Contributor

@crickman crickman commented Oct 4, 2024

Motivation and Context

When default KernelArguments are specified for KernelAgent.Arguments, it is likely expected that when override arguments parameter is provided that this override doesn't necessarily invalidate the default KernelArguments.ExecutionSettings.

Description

Provide performant merge logic for default and override KernelArguments for all invocations.
This merge preserves any default values not specifically included in the override...including both ExecutionSettings and parameters.

Solves this (common) pattern:

ChatCompletionAgent agent =
    new()
    {
        Name = "SampleAssistantAgent",
        Instructions =
            """
            Something something.
            
            Something dynamic: {{$topic}}

            The current date and time is: {{$now}}. 
            """,
        Kernel = kernel,
        Arguments =
            new KernelArguments(new AzureOpenAIPromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() })
            {
                { "topic", "default topic" }
            }
    };
    
KernelArguments arguments =
    new()
    {
        { "now", $"{now.ToShortDateString()} {now.ToShortTimeString()}" }
    };
await foreach (ChatMessageContent response in agent.InvokeAsync(history, arguments))
{
    ...
} 	

Contribution Checklist

@crickman crickman added PR: ready for review All feedback addressed, ready for reviews .NET Issue or Pull requests regarding .NET code agents labels Oct 4, 2024
@crickman crickman self-assigned this Oct 4, 2024
@crickman crickman requested a review from a team as a code owner October 4, 2024 20:25
@crickman crickman added this pull request to the merge queue Oct 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 4, 2024
@crickman crickman added this pull request to the merge queue Oct 4, 2024
Merged via the queue into main with commit 81953f2 Oct 4, 2024
15 checks passed
@crickman crickman deleted the fix-agent-argument-override branch October 4, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents .NET Issue or Pull requests regarding .NET code PR: ready for review All feedback addressed, ready for reviews
Projects
Status: Sprint: Done
Development

Successfully merging this pull request may close these issues.

3 participants