Repository: microsoft/semantic-kernel
File: dotnet/src/IntegrationTests/Plugins/ContextualFunctionProviderTests.cs (C#)

Code before:
        this._vectorStore = new InMemoryVectorStore(new InMemoryVectorStoreOptions() { EmbeddingGenerator = embeddingGenerator });

        var builder = Kernel.CreateBuilder();
        builder.AddAzureOpenAIChatCompletion(azureOpenAIConfiguration.DeploymentName, azureOpenAIConfiguration.Endpoint, new AzureCliCredential());
        this._kernel = builder.Build();
    }

    [Fact]
    private async Task ItShouldSelectFunctionsRelevantToCurrentInvocationContextAsync()
    {
        // Arrange
        IList<AIFunction>? relevantFunctions = null;

        void OnModelInvokingAsync(ICollection<ChatMessage> newMessages, AIContext context)
        {
            relevantFunctions = context.AIFunctions;
        }

        ChatCompletionAgent agent =
            new()
            {
                Name = "ReviewGuru",
                Instructions = "You are a friendly assistant that summarizes key points and sentiments from customer reviews.",
                Kernel = this._kernel,
                Arguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new FunctionChoiceBehaviorOptions { RetainArgumentTypes = true }) })
            };

        ContextualFunctionProvider provider = new(
            vectorStore: this._vectorStore,
            vectorDimensions: 1536,
            functions: GetAvailableFunctions(),
            maxNumberOfFunctions: 3
        );

        ChatHistoryAgentThread agentThread = new();
        agentThread.AIContextProviders.Add(new AIContextProviderDecorator(provider, OnModelInvokingAsync));

        // Act
        await agent.InvokeAsync("Get latest customer reviews and identify trends in sentiment.", agentThread).FirstAsync();

        // Assert
        Assert.NotNull(relevantFunctions);
        Assert.Contains(relevantFunctions, f => f.Name == "GetCustomerReviews");
        Assert.Contains(relevantFunctions, f => f.Name == "IdentifySentimentTrend");
    }

    [Fact]
    private async Task ItShouldSelectFunctionsBasedOnPreviousAndCurrentInvocationContextAsync()
    {
        // Arrange
        IList<AIFunction>? relevantFunctions = null;

Review comment (suggestion):
nit

```suggestion
                Arguments = new(new() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new() { RetainArgumentTypes = true }) })
```

Code after:

        this._vectorStore = new InMemoryVectorStore(new InMemoryVectorStoreOptions() { EmbeddingGenerator = embeddingGenerator });

        var builder = Kernel.CreateBuilder();
        builder.AddAzureOpenAIChatCompletion(chatConfig.DeploymentName, chatConfig.Endpoint, new AzureCliCredential());
        this._kernel = builder.Build();
    }

    [Fact]
    private async Task ItShouldSelectFunctionsRelevantToCurrentInvocationContextAsync()
    {
        // Arrange
        IList<AIFunction>? relevantFunctions = null;

        void OnModelInvokingAsync(ICollection<ChatMessage> newMessages, AIContext context)
        {
            relevantFunctions = context.AIFunctions;
        }

        ChatCompletionAgent agent =
            new()
            {
                Name = "ReviewGuru",
                Instructions = "You are a friendly assistant that summarizes key points and sentiments from customer reviews.",
                Kernel = this._kernel,
                Arguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new FunctionChoiceBehaviorOptions { RetainArgumentTypes = true }) })
            };

        ContextualFunctionProvider provider = new(
            vectorStore: this._vectorStore,
            vectorDimensions: this._modelDimensions,
            functions: GetAvailableFunctions(),
            maxNumberOfFunctions: 3
        );

        ChatHistoryAgentThread agentThread = new();
        agentThread.AIContextProviders.Add(new AIContextProviderDecorator(provider, OnModelInvokingAsync));

        // Act
        await agent.InvokeAsync("Get latest customer reviews and identify trends in sentiment.", agentThread).FirstAsync();

        // Assert
        Assert.NotNull(relevantFunctions);
        Assert.Contains(relevantFunctions, f => f.Name == "GetCustomerReviews");
        Assert.Contains(relevantFunctions, f => f.Name == "IdentifySentimentTrend");
    }

    [Fact]
    private async Task ItShouldSelectFunctionsBasedOnPreviousAndCurrentInvocationContextAsync()
    {
        // Arrange