diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs index fd3ff10fc2..f104f12890 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs @@ -142,7 +142,7 @@ public InvokingContext(IEnumerable requestMessages) /// /// A collection of instances representing new messages that were provided by the caller. /// - public IEnumerable RequestMessages { get; } + public IEnumerable RequestMessages { get; set { field = Throw.IfNull(value); } } } /// @@ -174,7 +174,7 @@ public InvokedContext(IEnumerable requestMessages, IEnumerable instances representing new messages that were provided by the caller. /// This does not include any supplied messages. /// - public IEnumerable RequestMessages { get; } + public IEnumerable RequestMessages { get; set { field = Throw.IfNull(value); } } /// /// Gets the messages provided by the for this invocation, if any. @@ -183,7 +183,7 @@ public InvokedContext(IEnumerable requestMessages, IEnumerable instances that were provided by the , /// and were used by the agent as part of the invocation. /// - public IEnumerable? AIContextProviderMessages { get; } + public IEnumerable? AIContextProviderMessages { get; set; } /// /// Gets the collection of response messages generated during this invocation if the invocation succeeded. diff --git a/dotnet/src/Microsoft.Agents.AI.Abstractions/ChatMessageStore.cs b/dotnet/src/Microsoft.Agents.AI.Abstractions/ChatMessageStore.cs index d28cd191b7..54cee063d7 100644 --- a/dotnet/src/Microsoft.Agents.AI.Abstractions/ChatMessageStore.cs +++ b/dotnet/src/Microsoft.Agents.AI.Abstractions/ChatMessageStore.cs @@ -152,7 +152,7 @@ public InvokingContext(IEnumerable requestMessages) /// /// A collection of instances representing new messages that were provided by the caller. /// - public IEnumerable RequestMessages { get; } + public IEnumerable RequestMessages { get; set { field = Throw.IfNull(value); } } } /// @@ -174,7 +174,7 @@ public sealed class InvokedContext public InvokedContext(IEnumerable requestMessages, IEnumerable chatMessageStoreMessages) { this.RequestMessages = Throw.IfNull(requestMessages); - this.ChatMessageStoreMessages = chatMessageStoreMessages; + this.ChatMessageStoreMessages = Throw.IfNull(chatMessageStoreMessages); } /// @@ -184,7 +184,7 @@ public InvokedContext(IEnumerable requestMessages, IEnumerable instances representing new messages that were provided by the caller. /// This does not include any supplied messages. /// - public IEnumerable RequestMessages { get; } + public IEnumerable RequestMessages { get; set { field = Throw.IfNull(value); } } /// /// Gets the messages retrieved from the for this invocation, if any. @@ -193,7 +193,7 @@ public InvokedContext(IEnumerable requestMessages, IEnumerable instances that were retrieved from the , /// and were used by the agent as part of the invocation. /// - public IEnumerable ChatMessageStoreMessages { get; } + public IEnumerable ChatMessageStoreMessages { get; set { field = Throw.IfNull(value); } } /// /// Gets or sets the messages provided by the for this invocation, if any. diff --git a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs index 0c02932b0a..8f6d6a5160 100644 --- a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs @@ -692,7 +692,7 @@ private async Task List inputMessagesForChatClient = []; IList? aiContextProviderMessages = null; - IList? chatMessageStoreMessages = null; + IList? chatMessageStoreMessages = []; // Populate the thread messages only if we are not continuing an existing response as it's not allowed if (chatOptions?.ContinuationToken is null)