diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs index c46d7f43156..16e9d62f25b 100644 --- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs +++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs @@ -82,15 +82,14 @@ public FunctionInvokingChatClient(IChatClient innerClient) /// /// /// An individual response from the inner client may contain multiple function call requests. - /// By default, such function calls may be issued to execute concurrently with each other. Set - /// to false to disable such concurrent invocation and force - /// the functions to be invoked serially. + /// By default, such function calls are processed serially. Set to + /// to enable concurrent invocation such that multiple function calls may execute in parallel. /// /// - /// The default value is . + /// The default value is . /// /// - public bool ConcurrentInvocation { get; set; } = true; + public bool ConcurrentInvocation { get; set; } /// /// Gets or sets a value indicating whether to keep intermediate messages in the chat history. diff --git a/test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs b/test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs index 8ad0c6d7944..20780d968f7 100644 --- a/test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs +++ b/test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs @@ -12,6 +12,19 @@ namespace Microsoft.Extensions.AI; public class FunctionInvokingChatClientTests { + [Fact] + public void Ctor_HasExpectedDefaults() + { + using TestChatClient innerClient = new(); + using FunctionInvokingChatClient client = new(innerClient); + + Assert.False(client.ConcurrentInvocation); + Assert.False(client.DetailedErrors); + Assert.True(client.KeepFunctionCallingMessages); + Assert.Null(client.MaximumIterationsPerRequest); + Assert.False(client.RetryOnError); + } + [Fact] public async Task SupportsSingleFunctionCallPerRequestAsync() { @@ -71,7 +84,7 @@ await InvokeAndAssertAsync(options, [ } [Fact] - public async Task ParallelFunctionCallsInvokedConcurrentlyByDefaultAsync() + public async Task ParallelFunctionCallsMayBeInvokedConcurrentlyAsync() { using var barrier = new Barrier(2); @@ -97,11 +110,11 @@ await InvokeAndAssertAsync(options, [ new FunctionResultContent("callId2", "Func", result: "worldworld"), ]), new ChatMessage(ChatRole.Assistant, "done"), - ]); + ], configurePipeline: b => b.Use(s => new FunctionInvokingChatClient(s) { ConcurrentInvocation = true })); } [Fact] - public async Task ConcurrentInvocationOfParallelCallsCanBeDisabledAsync() + public async Task ConcurrentInvocationOfParallelCallsDisabledByDefaultAsync() { int activeCount = 0; @@ -130,7 +143,7 @@ await InvokeAndAssertAsync(options, [ new FunctionResultContent("callId2", "Func", result: "worldworld"), ]), new ChatMessage(ChatRole.Assistant, "done"), - ], configurePipeline: b => b.Use(s => new FunctionInvokingChatClient(s) { ConcurrentInvocation = false })); + ]); } [Theory]