diff --git a/dotnet/samples/Concepts/Agents/OpenAIAssistant_Streaming.cs b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Streaming.cs index b070b8cf6ef8..d3a757187429 100644 --- a/dotnet/samples/Concepts/Agents/OpenAIAssistant_Streaming.cs +++ b/dotnet/samples/Concepts/Agents/OpenAIAssistant_Streaming.cs @@ -83,7 +83,7 @@ private async Task InvokeAgentAsync(OpenAIAssistantAgent agent, string threadId, ChatHistory history = []; bool isFirst = false; - await foreach (StreamingChatMessageContent response in agent.InvokeStreamingAsync(threadId, history)) + await foreach (StreamingChatMessageContent response in agent.InvokeStreamingAsync(threadId, messages: history)) { if (string.IsNullOrEmpty(response.Content)) { diff --git a/dotnet/src/Agents/OpenAI/Internal/AssistantThreadActions.cs b/dotnet/src/Agents/OpenAI/Internal/AssistantThreadActions.cs index 643f9dbb1dcc..5eea56fddfc2 100644 --- a/dotnet/src/Agents/OpenAI/Internal/AssistantThreadActions.cs +++ b/dotnet/src/Agents/OpenAI/Internal/AssistantThreadActions.cs @@ -348,7 +348,7 @@ public static async IAsyncEnumerable InvokeStreamin OpenAIAssistantAgent agent, AssistantClient client, string threadId, - IList messages, + IList? messages, OpenAIAssistantInvocationOptions? invocationOptions, ILogger logger, Kernel kernel, @@ -413,7 +413,7 @@ public static async IAsyncEnumerable InvokeStreamin if (functionCalls.Length > 0) { // Emit function-call content - messages.Add(GenerateFunctionCallContent(agent.GetName(), functionCalls)); + messages?.Add(GenerateFunctionCallContent(agent.GetName(), functionCalls)); // Invoke functions for each tool-step IEnumerable> functionResultTasks = ExecuteFunctionSteps(agent, functionCalls, cancellationToken); @@ -425,7 +425,7 @@ public static async IAsyncEnumerable InvokeStreamin ToolOutput[] toolOutputs = GenerateToolOutputs(functionResults); asyncUpdates = client.SubmitToolOutputsToRunStreamingAsync(run, toolOutputs); - messages.Add(GenerateFunctionResultsContent(agent.GetName(), functionResults)); + messages?.Add(GenerateFunctionResultsContent(agent.GetName(), functionResults)); } } @@ -440,7 +440,7 @@ public static async IAsyncEnumerable InvokeStreamin if (message != null) { ChatMessageContent content = GenerateMessageContent(agent.GetName(), message); - messages.Add(content); + messages?.Add(content); } } diff --git a/dotnet/src/Agents/OpenAI/OpenAIAssistantAgent.cs b/dotnet/src/Agents/OpenAI/OpenAIAssistantAgent.cs index a7c579ffc272..1e79fa31b95d 100644 --- a/dotnet/src/Agents/OpenAI/OpenAIAssistantAgent.cs +++ b/dotnet/src/Agents/OpenAI/OpenAIAssistantAgent.cs @@ -298,9 +298,9 @@ public async IAsyncEnumerable InvokeAsync( /// Invoke the assistant on the specified thread. /// /// The thread identifier - /// The receiver for the completed messages generated /// Optional arguments to pass to the agents's invocation, including any . /// The containing services, plugins, and other state for use by the agent. + /// Optional receiver of the completed messages generated /// The to monitor for cancellation requests. The default is . /// Asynchronous enumeration of messages. /// @@ -308,20 +308,20 @@ public async IAsyncEnumerable InvokeAsync( /// public IAsyncEnumerable InvokeStreamingAsync( string threadId, - ChatHistory messages, KernelArguments? arguments = null, Kernel? kernel = null, + ChatHistory? messages = null, CancellationToken cancellationToken = default) - => this.InvokeStreamingAsync(threadId, messages, options: null, arguments, kernel, cancellationToken); + => this.InvokeStreamingAsync(threadId, options: null, arguments, kernel, messages, cancellationToken); /// /// Invoke the assistant on the specified thread. /// /// The thread identifier - /// The receiver for the completed messages generated /// Optional invocation options /// Optional arguments to pass to the agents's invocation, including any . /// The containing services, plugins, and other state for use by the agent. + /// Optional receiver of the completed messages generated /// The to monitor for cancellation requests. The default is . /// Asynchronous enumeration of messages. /// @@ -329,10 +329,10 @@ public IAsyncEnumerable InvokeStreamingAsync( /// public IAsyncEnumerable InvokeStreamingAsync( string threadId, - ChatHistory messages, OpenAIAssistantInvocationOptions? options, KernelArguments? arguments = null, Kernel? kernel = null, + ChatHistory? messages = null, CancellationToken cancellationToken = default) { this.ThrowIfDeleted();