diff --git a/dotnet/samples/GettingStarted/GettingStarted.csproj b/dotnet/samples/GettingStarted/GettingStarted.csproj
index e42dca525..b34401f6d 100644
--- a/dotnet/samples/GettingStarted/GettingStarted.csproj
+++ b/dotnet/samples/GettingStarted/GettingStarted.csproj
@@ -9,7 +9,7 @@
GettingStarted
Library
5ee045b0-aea3-4f08-8d31-32d1a6f8fed0
- $(NoWarn);CA1707;CA1716;IDE0009;IDE1006;
+ $(NoWarn);CA1707;CA1716;IDE0009;IDE1006;OPENAI001;
enable
true
diff --git a/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_AzureOpenAIChatCompletion.cs b/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_AzureOpenAIChatCompletion.cs
index aca7d81c7..e52c7a5d3 100644
--- a/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_AzureOpenAIChatCompletion.cs
+++ b/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_AzureOpenAIChatCompletion.cs
@@ -29,12 +29,7 @@ public async Task RunWithChatCompletion()
.AsIChatClient();
// Define the agent
- ChatClientAgent agent =
- new(chatClient, new()
- {
- Name = JokerName,
- Instructions = JokerInstructions,
- });
+ ChatClientAgent agent = new(chatClient, JokerInstructions, JokerName);
// Start a new thread for the agent conversation.
AgentThread thread = agent.GetNewThread();
diff --git a/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIChatCompletion.cs b/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIChatCompletion.cs
index ced1a2d49..e21cf5e3a 100644
--- a/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIChatCompletion.cs
+++ b/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIChatCompletion.cs
@@ -24,12 +24,7 @@ public async Task RunWithChatCompletion()
.AsIChatClient();
// Define the agent
- ChatClientAgent agent =
- new(chatClient, new()
- {
- Name = JokerName,
- Instructions = JokerInstructions,
- });
+ ChatClientAgent agent = new(chatClient, JokerInstructions, JokerName);
// Start a new thread for the agent conversation.
AgentThread thread = agent.GetNewThread();
diff --git a/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIResponseChatCompletion.cs b/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIResponseChatCompletion.cs
index 231f9a2d7..3e3489da4 100644
--- a/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIResponseChatCompletion.cs
+++ b/dotnet/samples/GettingStarted/Providers/ChatClientAgent_With_OpenAIResponseChatCompletion.cs
@@ -6,8 +6,6 @@
using OpenAI;
using OpenAI.Responses;
-#pragma warning disable CS8524 // The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value.
-
namespace Providers;
///
@@ -18,29 +16,63 @@ public sealed class ChatClientAgent_With_OpenAIResponsesChatCompletion(ITestOutp
private const string JokerName = "Joker";
private const string JokerInstructions = "You are good at telling jokes.";
- [Theory]
- [InlineData(false)] // This will use in-memory messages to store the thread state.
- [InlineData(true)] // This will use the conversation id to reference the thread state on the server side.
- public async Task RunWithChatCompletion(bool useConversationIdThread)
+ ///
+ /// This will use the conversation id to reference the thread state on the server side.
+ ///
+ [Fact]
+ public async Task RunWithChatCompletionServiceManagedThread()
+ {
+ // Get the chat client to use for the agent.
+ using var chatClient = new OpenAIClient(TestConfiguration.OpenAI.ApiKey)
+ .GetOpenAIResponseClient(TestConfiguration.OpenAI.ChatModelId)
+ .AsIChatClient();
+
+ // Define the agent
+ ChatClientAgent agent = new(chatClient, JokerInstructions, JokerName);
+
+ // Start a new thread for the agent conversation based on the type.
+ AgentThread thread = agent.GetNewThread();
+
+ // Respond to user input.
+ await RunAgentAsync("Tell me a joke about a pirate.");
+ await RunAgentAsync("Now add some emojis to the joke.");
+
+ // Local function to invoke agent and display the conversation messages for the thread.
+ async Task RunAgentAsync(string input)
+ {
+ this.WriteUserMessage(input);
+
+ var response = await agent.RunAsync(input, thread);
+
+ this.WriteResponseOutput(response);
+ }
+ }
+
+ ///
+ /// This will use in-memory messages to store the thread state.
+ ///
+ [Fact]
+ public async Task RunWithChatCompletionInMemoryThread()
{
// Get the chat client to use for the agent.
-#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
using var chatClient = new OpenAIClient(TestConfiguration.OpenAI.ApiKey)
.GetOpenAIResponseClient(TestConfiguration.OpenAI.ChatModelId)
.AsIChatClient();
// Define the agent
ChatClientAgent agent =
- new(chatClient, new()
+ new(chatClient, options: new()
{
Name = JokerName,
Instructions = JokerInstructions,
ChatOptions = new ChatOptions
{
- RawRepresentationFactory = (_) => new ResponseCreationOptions() { StoredOutputEnabled = useConversationIdThread }
+ // We can use the RawRepresentationFactory to provide Response service specific
+ // options. Here we can indicate that we do not want the service to store the
+ // conversation in a service managed thread.
+ RawRepresentationFactory = (_) => new ResponseCreationOptions() { StoredOutputEnabled = false }
}
});
-#pragma warning restore OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
// Start a new thread for the agent conversation based on the type.
AgentThread thread = agent.GetNewThread();
diff --git a/dotnet/samples/GettingStarted/Steps/Step01_ChatClientAgent_Running.cs b/dotnet/samples/GettingStarted/Steps/Step01_ChatClientAgent_Running.cs
index 8951ee4c1..9d02b2550 100644
--- a/dotnet/samples/GettingStarted/Steps/Step01_ChatClientAgent_Running.cs
+++ b/dotnet/samples/GettingStarted/Steps/Step01_ChatClientAgent_Running.cs
@@ -33,11 +33,7 @@ public async Task RunBasic(ChatClientProviders provider)
IChatClient chatClient = base.GetChatClient(provider);
// Define the agent
- Agent agent = new ChatClientAgent(chatClient, options: new()
- {
- Name = ParrotName,
- Instructions = ParrotInstructions,
- });
+ Agent agent = new ChatClientAgent(chatClient, ParrotInstructions, ParrotName);
// Invoke the agent and output the text result.
Console.WriteLine(await agent.RunAsync("Fortune favors the bold."));
diff --git a/dotnet/samples/GettingStarted/Steps/Step02_ChatClientAgent_UsingFunctionTools.cs b/dotnet/samples/GettingStarted/Steps/Step02_ChatClientAgent_UsingFunctionTools.cs
index ca0b8934a..41f695903 100644
--- a/dotnet/samples/GettingStarted/Steps/Step02_ChatClientAgent_UsingFunctionTools.cs
+++ b/dotnet/samples/GettingStarted/Steps/Step02_ChatClientAgent_UsingFunctionTools.cs
@@ -12,12 +12,33 @@ namespace Steps;
///
public sealed class Step02_ChatClientAgent_UsingFunctionTools(ITestOutputHelper output) : AgentSample(output)
{
+ [Theory]
+ [InlineData(ChatClientProviders.AzureOpenAI)]
+ [InlineData(ChatClientProviders.OpenAIChatCompletion)]
+ public async Task RunningWithToolsBasic(ChatClientProviders provider)
+ {
+ // Creating a MenuTools instance to be used by the agent.
+ var menuTools = new MenuTools();
+
+ // Get the chat client to use for the agent.
+ var chatClient = base.GetChatClient(provider);
+
+ // Define the agent and add the GetSpecials tool.
+ var agent = new ChatClientAgent(
+ chatClient,
+ instructions: "Answer questions about the menu.",
+ tools: [AIFunctionFactory.Create(menuTools.GetSpecials)]);
+
+ // Respond to user input, invoking functions where appropriate.
+ Console.WriteLine(await agent.RunAsync("What is the special soup and its price?"));
+ }
+
[Theory]
[InlineData(ChatClientProviders.AzureOpenAI)]
[InlineData(ChatClientProviders.OpenAIChatCompletion)]
public async Task RunningWithTools(ChatClientProviders provider)
{
- // Creating a Menu Tools to be used by the agent.
+ // Creating a MenuTools instance to be used by the agent.
var menuTools = new MenuTools();
// Define the options for the chat client agent.
@@ -65,7 +86,7 @@ async Task RunAgentAsync(string input)
[InlineData(ChatClientProviders.OpenAIChatCompletion)]
public async Task StreamingRunWithTools(ChatClientProviders provider)
{
- // Creating a Menu Tools to be used by the agent.
+ // Creating a MenuTools instance to be used by the agent.
var menuTools = new MenuTools();
// Define the options for the chat client agent.
diff --git a/dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs b/dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs
index 20c92cfe7..fbc98f486 100644
--- a/dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs
+++ b/dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs
@@ -105,7 +105,6 @@ private async Task UploadFileAsync(string filePath, ChatClientProviders
/// The code interpreter output as a string.
private static string? GetCodeInterpreterOutput(object rawRepresentation, ChatClientProviders provider)
{
-#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
switch (provider)
{
case ChatClientProviders.OpenAIAssistant
@@ -114,7 +113,6 @@ private async Task UploadFileAsync(string filePath, ChatClientProviders
string.Empty,
stepDetails.CodeInterpreterOutputs.SelectMany(l => l.Logs)
)}";
-#pragma warning restore OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
case ChatClientProviders.AzureAIAgentsPersistent
when rawRepresentation is Azure.AI.Agents.Persistent.RunStepDetailsUpdate stepDetails:
diff --git a/dotnet/src/Microsoft.Extensions.AI.Agents/ChatCompletion/ChatClientAgent.cs b/dotnet/src/Microsoft.Extensions.AI.Agents/ChatCompletion/ChatClientAgent.cs
index feaf07969..b0e840a98 100644
--- a/dotnet/src/Microsoft.Extensions.AI.Agents/ChatCompletion/ChatClientAgent.cs
+++ b/dotnet/src/Microsoft.Extensions.AI.Agents/ChatCompletion/ChatClientAgent.cs
@@ -25,9 +25,35 @@ public sealed class ChatClientAgent : Agent
/// Initializes a new instance of the class.
///
/// The chat client to use for invoking the agent.
- /// Optional agent options to configure the agent.
+ /// Optional instructions for the agent.
+ /// Optional name for the agent.
+ /// Optional description for the agent.
+ /// Optional list of tools that the agent can use during invocation.
/// Optional logger factory to use for logging.
- public ChatClientAgent(IChatClient chatClient, ChatClientAgentOptions? options = null, ILoggerFactory? loggerFactory = null)
+ public ChatClientAgent(IChatClient chatClient, string? instructions = null, string? name = null, string? description = null, IList? tools = null, ILoggerFactory? loggerFactory = null)
+ : this(
+ chatClient,
+ new ChatClientAgentOptions()
+ {
+ Name = name,
+ Description = description,
+ Instructions = instructions,
+ ChatOptions = tools is null ? null : new ChatOptions()
+ {
+ Tools = tools,
+ }
+ },
+ loggerFactory)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The chat client to use for invoking the agent.
+ /// Full set of options to configure the agent.
+ /// Optional logger factory to use for logging.
+ public ChatClientAgent(IChatClient chatClient, ChatClientAgentOptions options, ILoggerFactory? loggerFactory = null)
{
Throw.IfNull(chatClient);
diff --git a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentFixture.cs b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentFixture.cs
index 64a67e530..ec98b9964 100644
--- a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentFixture.cs
+++ b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentFixture.cs
@@ -73,7 +73,7 @@ public async Task CreateChatClientAgentAsync(
return new ChatClientAgent(
this._persistentAgentsClient.AsIChatClient(persistentAgent.Id),
- new()
+ options: new()
{
Id = persistentAgent.Id,
ChatOptions = new() { Tools = aiTools }
diff --git a/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentExtensionsTests.cs b/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentExtensionsTests.cs
index f98e5d14f..1152e6da0 100644
--- a/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentExtensionsTests.cs
+++ b/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentExtensionsTests.cs
@@ -27,7 +27,7 @@ public async Task RunAsyncWithMessagesWorksWithValidParametersAsync()
It.IsAny(),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test message") };
// Act & Assert - Should not throw
@@ -59,7 +59,7 @@ public async Task RunAsyncWithMessagesThrowsArgumentNullExceptionWhenMessagesIsN
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(chatClient, options: new() { Instructions = "test instructions" });
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -82,7 +82,7 @@ public async Task RunAsyncWithMessagesWorksWithChatOptionsAsync()
It.IsAny(),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
// Act - Call extension method (should not throw)
@@ -115,7 +115,7 @@ public async Task RunAsyncWithMessagesPassesInstructionsCorrectlyAsync()
})
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "base instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "base instructions" });
var messages = new List { new(ChatRole.User, "test") };
var runOptions = new AgentRunOptions();
@@ -142,7 +142,7 @@ public async Task RunAsyncWithMessagesWorksWithThreadParameterAsync()
It.IsAny(),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
var thread = agent.GetNewThread();
@@ -177,7 +177,7 @@ public async Task RunAsyncWithMessagesRespectsCancellationTokenAsync()
It.IsAny(),
It.IsAny())).ThrowsAsync(new OperationCanceledException());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
// Act & Assert
@@ -202,7 +202,7 @@ public async Task RunAsyncWithPromptCallsUnderlyingAgentMethodAsync()
It.IsAny(),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act
@@ -244,7 +244,7 @@ public async Task RunAsyncWithPromptThrowsArgumentNullExceptionWhenPromptIsNullA
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(chatClient, options: new() { Instructions = "test instructions" });
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -260,7 +260,7 @@ public async Task RunAsyncWithPromptThrowsArgumentExceptionWhenPromptIsWhitespac
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(chatClient, options: new() { Instructions = "test instructions" });
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -286,7 +286,7 @@ public async Task RunAsyncWithPromptConvertsPromptToChatMessageCorrectlyAsync()
capturedMessages.AddRange(msgs))
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act
@@ -312,7 +312,7 @@ public async Task RunAsyncWithPromptPassesChatOptionsCorrectlyAsync()
It.Is(opts => opts.MaxOutputTokens == 200),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act
@@ -345,7 +345,7 @@ public async Task RunAsyncWithPromptPassesAgentRunOptionsCorrectlyAsync()
capturedMessages.AddRange(msgs))
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "base instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "base instructions" });
const string TestPrompt = "test prompt";
var runOptions = new AgentRunOptions();
@@ -371,7 +371,7 @@ public async Task RunAsyncWithPromptWorksWithThreadParameterAsync()
It.IsAny(),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
var thread = agent.GetNewThread();
@@ -406,7 +406,7 @@ public async Task RunAsyncWithPromptRespectsCancellationTokenAsync()
It.IsAny(),
It.IsAny())).ThrowsAsync(new OperationCanceledException());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act & Assert
@@ -437,7 +437,7 @@ public async Task RunStreamingAsyncWithMessagesCallsUnderlyingAgentMethodAsync()
It.IsAny(),
It.IsAny())).Returns(returnUpdates.ToAsyncEnumerable());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test message") };
// Act
@@ -488,7 +488,7 @@ public async Task RunStreamingAsyncWithMessagesThrowsArgumentNullExceptionWhenMe
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(chatClient, options: new() { Instructions = "test instructions" });
// Act & Assert
var exception = await Assert.ThrowsAsync(async () =>
@@ -518,7 +518,7 @@ public async Task RunStreamingAsyncWithMessagesPassesChatOptionsCorrectlyAsync()
It.Is(opts => opts.MaxOutputTokens == 100),
It.IsAny())).Returns(returnUpdates.ToAsyncEnumerable());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
// Act
@@ -554,7 +554,7 @@ public async Task RunStreamingAsyncWithMessagesWorksWithThreadParameterAsync()
It.IsAny(),
It.IsAny())).Returns(returnUpdates.ToAsyncEnumerable());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
var thread = agent.GetNewThread();
@@ -592,7 +592,7 @@ public async Task RunStreamingAsyncWithMessagesRespectsCancellationTokenAsync()
It.IsAny(),
It.IsAny())).Throws(new OperationCanceledException());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
// Act & Assert
@@ -629,7 +629,7 @@ public async Task RunStreamingAsyncWithPromptCallsUnderlyingAgentMethodAsync()
It.IsAny(),
It.IsAny())).Returns(returnUpdates.ToAsyncEnumerable());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act
@@ -680,7 +680,7 @@ public async Task RunStreamingAsyncWithPromptThrowsArgumentNullExceptionWhenProm
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(chatClient, options: new() { Instructions = "test instructions" });
// Act & Assert
var exception = await Assert.ThrowsAsync(async () =>
@@ -701,7 +701,7 @@ public async Task RunStreamingAsyncWithPromptThrowsArgumentExceptionWhenPromptIs
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(chatClient, options: new() { Instructions = "test instructions" });
// Act & Assert
var exception = await Assert.ThrowsAsync(async () =>
@@ -734,7 +734,7 @@ public async Task RunStreamingAsyncWithPromptConvertsPromptToChatMessageCorrectl
capturedMessages.AddRange(msgs))
.Returns(returnUpdates.ToAsyncEnumerable());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act
@@ -767,7 +767,7 @@ public async Task RunStreamingAsyncWithPromptPassesChatOptionsCorrectlyAsync()
It.Is(opts => opts.MaxOutputTokens == 200),
It.IsAny())).Returns(returnUpdates.ToAsyncEnumerable());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act
@@ -803,7 +803,7 @@ public async Task RunStreamingAsyncWithPromptWorksWithThreadParameterAsync()
It.IsAny(),
It.IsAny())).Returns(returnUpdates.ToAsyncEnumerable());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
var thread = agent.GetNewThread();
@@ -841,7 +841,7 @@ public async Task RunStreamingAsyncWithPromptRespectsCancellationTokenAsync()
It.IsAny(),
It.IsAny())).Throws(new OperationCanceledException());
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
const string TestPrompt = "test prompt";
// Act & Assert
diff --git a/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentTests.cs b/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentTests.cs
index de0ce57fd..aa3bfd892 100644
--- a/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentTests.cs
+++ b/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentTests.cs
@@ -21,7 +21,7 @@ public void VerifyChatClientAgentDefinition()
var chatClient = new Mock().Object;
ChatClientAgent agent =
new(chatClient,
- new()
+ options: new()
{
Id = "test-agent-id",
Name = "test name",
@@ -54,7 +54,7 @@ public async Task VerifyChatClientAgentInvocationAsync()
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "I'm here!")]));
ChatClientAgent agent =
- new(mockService.Object, new()
+ new(mockService.Object, options: new()
{
Instructions = "test instructions"
});
@@ -90,7 +90,7 @@ public async Task RunAsyncThrowsArgumentNullExceptionWhenMessagesIsNullAsync()
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(chatClient, options: new() { Instructions = "test instructions" });
// Act & Assert
await Assert.ThrowsAsync(() => agent.RunAsync((IReadOnlyCollection)null!));
@@ -111,7 +111,7 @@ public async Task RunAsyncPassesChatOptionsWhenUsingChatClientAgentRunOptionsAsy
It.Is(opts => opts.MaxOutputTokens == 100),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
// Act
await agent.RunAsync([new(ChatRole.User, "test")], chatOptions: chatOptions);
@@ -139,7 +139,7 @@ public async Task RunAsyncPassesNullChatOptionsWhenUsingRegularAgentRunOptionsAs
null,
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var runOptions = new AgentRunOptions();
// Act
@@ -172,7 +172,7 @@ public async Task RunAsyncIncludesBaseInstructionsAsync()
capturedMessages.AddRange(msgs))
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "base instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "base instructions" });
var runOptions = new AgentRunOptions();
// Act
@@ -202,7 +202,7 @@ public async Task RunAsyncSetsAuthorNameOnAllResponseMessagesAsync()
It.IsAny(),
It.IsAny())).ReturnsAsync(new ChatResponse(responseMessages));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions", Name = "TestAgent" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions", Name = "TestAgent" });
// Act
var result = await agent.RunAsync([new(ChatRole.User, "test")]);
@@ -229,7 +229,7 @@ public async Task RunAsyncRetrievesMessagesFromThreadWhenThreadImplementsIMessag
capturedMessages.AddRange(msgs))
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
// Create a thread using the agent's GetNewThread method
var thread = agent.GetNewThread();
@@ -261,7 +261,7 @@ public async Task RunAsyncWorksWithoutInstructionsWhenInstructionsAreNullOrEmpty
capturedMessages.AddRange(msgs))
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = null });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = null });
// Act
await agent.RunAsync([new(ChatRole.User, "test message")]);
@@ -291,7 +291,7 @@ public async Task RunAsyncWorksWithEmptyMessagesWhenNoMessagesProvidedAsync()
capturedMessages.AddRange(msgs))
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
// Act
await agent.RunAsync([]);
@@ -319,7 +319,7 @@ public async Task RunAsyncDoesNotThrowWhenSpecifyingTwoSameThreadIdsAsync()
It.Is(opts => opts.ConversationId == "ConvId"),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]) { ConversationId = "ConvId" });
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
ChatClientAgentThread thread = new("ConvId");
@@ -338,7 +338,7 @@ public async Task RunAsyncThrowsWhenSpecifyingTwoDifferentThreadIdsAsync()
var chatOptions = new ChatOptions { ConversationId = "ConvId" };
Mock mockService = new();
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
ChatClientAgentThread thread = new("ThreadId");
@@ -361,7 +361,7 @@ public async Task RunAsyncClonesChatOptionsToAddThreadIdAsync()
It.Is(opts => opts.MaxOutputTokens == 100 && opts.ConversationId == "ConvId"),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]) { ConversationId = "ConvId" });
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
ChatClientAgentThread thread = new("ConvId");
@@ -386,7 +386,7 @@ public async Task RunAsyncThrowsForMissingConversationIdWithConversationIdThread
It.IsAny(),
It.IsAny())).ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
ChatClientAgentThread thread = new("ConvId");
@@ -419,7 +419,7 @@ public void IdFallsBackToBaseImplementationWhenMetadataIsNull()
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, null);
+ ChatClientAgent agent = new(chatClient);
// Act & Assert
Assert.NotNull(agent.Id);
@@ -469,7 +469,7 @@ public void NameReturnsNullWhenMetadataIsNull()
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, null);
+ ChatClientAgent agent = new(chatClient);
// Act & Assert
Assert.Null(agent.Name);
@@ -513,7 +513,7 @@ public void DescriptionReturnsNullWhenMetadataIsNull()
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, null);
+ ChatClientAgent agent = new(chatClient);
// Act & Assert
Assert.Null(agent.Description);
@@ -557,7 +557,7 @@ public void InstructionsReturnsNullWhenMetadataIsNull()
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, null);
+ ChatClientAgent agent = new(chatClient);
// Act & Assert
Assert.Null(agent.Instructions);
@@ -580,6 +580,68 @@ public void InstructionsReturnsNullWhenMetadataInstructionsIsNull()
#endregion
+ #region Options params Constructor Tests
+
+ ///
+ /// Checks that all params are set correctly when using the constructor with optional parameters.
+ ///
+ [Fact]
+ public void ConstructorUsesOptionalParams()
+ {
+ // Arrange
+ var chatClient = new Mock().Object;
+ ChatClientAgent agent = new(chatClient, instructions: "TestInstructions", name: "TestName", description: "TestDescription", tools: [AIFunctionFactory.Create(() => { })]);
+
+ // Act & Assert
+ Assert.Equal("TestInstructions", agent.Instructions);
+ Assert.Equal("TestName", agent.Name);
+ Assert.Equal("TestDescription", agent.Description);
+ Assert.NotNull(agent.ChatOptions);
+ Assert.NotNull(agent.ChatOptions.Tools);
+ Assert.Single(agent.ChatOptions.Tools!);
+ }
+
+ ///
+ /// Verify that ChatOptions property returns null when no params are provided that require a ChatOptions instance.
+ ///
+ [Fact]
+ public void ChatOptionsReturnsNullWhenConstructorToolsNotProvided()
+ {
+ // Arrange
+ var chatClient = new Mock().Object;
+ ChatClientAgent agent = new(chatClient, instructions: "TestInstructions", name: "TestName", description: "TestDescription");
+
+ // Act & Assert
+ Assert.Equal("TestInstructions", agent.Instructions);
+ Assert.Equal("TestName", agent.Name);
+ Assert.Equal("TestDescription", agent.Description);
+ Assert.Null(agent.ChatOptions);
+ }
+
+ #endregion
+
+ #region Options Constructor Tests
+
+ ///
+ /// Checks that the various properties on are null or defaulted when not provided to the constructor.
+ ///
+ [Fact]
+ public void OptionsPropertiesNullOrDefaultWhenNotProvidedToConstructor()
+ {
+ // Arrange
+ var chatClient = new Mock().Object;
+ ChatClientAgent agent = new(chatClient, options: null!);
+
+ // Act & Assert
+ Assert.NotNull(agent.Id);
+ Assert.Null(agent.Instructions);
+ Assert.Null(agent.Name);
+ Assert.Null(agent.Description);
+ Assert.Null(agent.ChatOptions);
+ }
+
+ #endregion
+
#region ChatOptions Property Tests
///
@@ -590,7 +652,7 @@ public void ChatOptionsReturnsNullWhenAgentOptionsAreNull()
{
// Arrange
var chatClient = new Mock().Object;
- ChatClientAgent agent = new(chatClient, null);
+ ChatClientAgent agent = new(chatClient);
// Act & Assert
Assert.Null(agent.ChatOptions);
@@ -656,7 +718,7 @@ public async Task ChatOptionsMergingUsesAgentOptionsWhenRequestHasNoneAsync()
capturedChatOptions = opts)
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new()
+ ChatClientAgent agent = new(mockService.Object, options: new()
{
Instructions = "test instructions",
ChatOptions = agentChatOptions
@@ -691,7 +753,7 @@ public async Task ChatOptionsMergingUsesRequestOptionsWhenAgentHasNoneAsync()
capturedChatOptions = opts)
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
// Act
@@ -746,7 +808,7 @@ public async Task ChatOptionsMergingPrioritizesRequestOptionsOverAgentOptionsAsy
capturedChatOptions = opts)
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new()
+ ChatClientAgent agent = new(mockService.Object, options: new()
{
Instructions = "test instructions",
ChatOptions = agentChatOptions
@@ -785,7 +847,7 @@ public async Task ChatOptionsMergingReturnsNullWhenBothAgentAndRequestHaveNoneAs
capturedChatOptions = opts)
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new() { Instructions = "test instructions" });
+ ChatClientAgent agent = new(mockService.Object, options: new() { Instructions = "test instructions" });
var messages = new List { new(ChatRole.User, "test") };
// Act
@@ -825,7 +887,7 @@ public async Task ChatOptionsMergingConcatenatesToolsFromAgentAndRequestAsync()
capturedChatOptions = opts)
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new()
+ ChatClientAgent agent = new(mockService.Object, options: new()
{
Instructions = "test instructions",
ChatOptions = agentChatOptions
@@ -874,7 +936,7 @@ public async Task ChatOptionsMergingUsesAgentToolsWhenRequestHasNoToolsAsync()
capturedChatOptions = opts)
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new()
+ ChatClientAgent agent = new(mockService.Object, options: new()
{
Instructions = "test instructions",
ChatOptions = agentChatOptions
@@ -891,6 +953,52 @@ public async Task ChatOptionsMergingUsesAgentToolsWhenRequestHasNoToolsAsync()
Assert.Contains(agentTool, capturedChatOptions.Tools); // Should contain the agent's tool
}
+ ///
+ /// Verify that ChatOptions merging uses RawRepresentationFactory from request first, with fallback to agent.
+ ///
+ [Theory]
+ [InlineData("MockAgentSetting", "MockRequestSetting", "MockRequestSetting")]
+ [InlineData("MockAgentSetting", null, "MockAgentSetting")]
+ [InlineData(null, "MockRequestSetting", "MockRequestSetting")]
+ public async Task ChatOptionsMergingUsesRawRepresentationFactoryWithFallbackAsync(string? agentSetting, string? requestSetting, string expectedSetting)
+ {
+ // Arrange
+ var agentChatOptions = new ChatOptions
+ {
+ RawRepresentationFactory = (_) => agentSetting
+ };
+ var requestChatOptions = new ChatOptions
+ {
+ RawRepresentationFactory = (_) => requestSetting
+ };
+
+ Mock mockService = new();
+ ChatOptions? capturedChatOptions = null;
+ mockService.Setup(
+ s => s.GetResponseAsync(
+ It.IsAny>(),
+ It.IsAny(),
+ It.IsAny()))
+ .Callback, ChatOptions, CancellationToken>((msgs, opts, ct) =>
+ capturedChatOptions = opts)
+ .ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
+
+ ChatClientAgent agent = new(mockService.Object, options: new()
+ {
+ Instructions = "test instructions",
+ ChatOptions = agentChatOptions
+ });
+ var messages = new List { new(ChatRole.User, "test") };
+
+ // Act
+ await agent.RunAsync(messages, chatOptions: requestChatOptions);
+
+ // Assert
+ Assert.NotNull(capturedChatOptions);
+ Assert.NotNull(capturedChatOptions.RawRepresentationFactory);
+ Assert.Equal(expectedSetting, capturedChatOptions.RawRepresentationFactory(null!));
+ }
+
///
/// Verify that ChatOptions merging handles all scalar properties correctly.
///
@@ -950,7 +1058,7 @@ public async Task ChatOptionsMergingHandlesAllScalarPropertiesCorrectlyAsync()
capturedChatOptions = opts)
.ReturnsAsync(new ChatResponse([new(ChatRole.Assistant, "response")]));
- ChatClientAgent agent = new(mockService.Object, new()
+ ChatClientAgent agent = new(mockService.Object, options: new()
{
Instructions = "test instructions",
ChatOptions = agentChatOptions
@@ -1007,7 +1115,7 @@ public async Task VerifyChatClientAgentStreamingAsync()
It.IsAny())).Returns(returnUpdates.ToAsyncEnumerable());
ChatClientAgent agent =
- new(mockService.Object, new()
+ new(mockService.Object, options: new()
{
Instructions = "test instructions"
});
diff --git a/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentThreadTests.cs b/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentThreadTests.cs
index e59311f83..5ff4dd7a7 100644
--- a/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentThreadTests.cs
+++ b/dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/ChatCompletion/ChatClientAgentThreadTests.cs
@@ -69,7 +69,7 @@ public async Task VerifyIMessagesRetrievableThreadGetMessagesAsyncWhenNotEmptyAs
.ReturnsAsync(new ChatResponse([assistantMessage]));
// Create ChatClientAgent with the mocked client
- var agent = new ChatClientAgent(mockChatClient.Object, new()
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new()
{
Instructions = "You are a helpful assistant"
});
@@ -190,7 +190,7 @@ public void ThreadCreationGeneratesValidThreadId()
It.IsAny()))
.ReturnsAsync(new ChatResponse([new ChatMessage(ChatRole.Assistant, "response")]));
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
// Act
var thread = agent.GetNewThread();
@@ -210,7 +210,7 @@ public void ThreadCreationGeneratesUniqueInstances()
{
// Arrange
var mockChatClient = new Mock();
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
// Act
var thread1 = agent.GetNewThread();
@@ -242,7 +242,7 @@ public async Task ThreadLifecycleStoresAndRetrievesMessagesAsync(string? respons
It.IsAny()))
.ReturnsAsync(new ChatResponse([assistantMessage]) { ConversationId = responseConversationId });
- var agent = new ChatClientAgent(mockChatClient.Object, new() { Instructions = "Test instructions" });
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new() { Instructions = "Test instructions" });
// Act
var thread = agent.GetNewThread();
@@ -298,7 +298,7 @@ public async Task ThreadMessageHandlingHandlesMultipleMessagesInOrderAsync()
.ReturnsAsync(new ChatResponse([messages[1]]))
.ReturnsAsync(new ChatResponse([messages[3]]));
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
var thread = agent.GetNewThread();
// Act - Add messages through multiple agent runs
@@ -349,7 +349,7 @@ public async Task VerifyThreadNotificationDuringStreamingAsync()
.Returns(returnUpdates.ToAsyncEnumerable());
// Create ChatClientAgent with the mocked client
- var agent = new ChatClientAgent(mockChatClient.Object, new()
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new()
{
Instructions = "You are a helpful assistant"
});
@@ -415,7 +415,7 @@ public async Task VerifyThreadAccumulatesMessagesAcrossMultipleStreamingCallsAsy
.Returns(firstReturnUpdates.ToAsyncEnumerable())
.Returns(secondReturnUpdates.ToAsyncEnumerable());
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
var thread = agent.GetNewThread();
// Act - Make two streaming calls
@@ -486,7 +486,7 @@ public async Task VerifyStreamingWithExistingThreadMessagesAsync()
It.IsAny()))
.Returns(streamingUpdates.ToAsyncEnumerable());
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
var thread = agent.GetNewThread();
// Act - First, make a regular call to populate the thread
@@ -538,7 +538,7 @@ public async Task VerifyThreadNotificationWithZeroStreamingUpdatesAsync()
It.IsAny()))
.Returns(returnUpdates.ToAsyncEnumerable());
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
var thread = agent.GetNewThread();
// Act - Run the agent with streaming that returns no updates
@@ -593,7 +593,7 @@ public async Task VerifyThreadNotificationWithMultipleStreamingUpdatesAsync()
It.IsAny()))
.Returns(returnUpdates.ToAsyncEnumerable());
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
var thread = agent.GetNewThread();
// Act - Run the agent with streaming that returns multiple updates
@@ -638,7 +638,7 @@ public async Task VerifyThreadNotNotifiedWhenStreamingThrowsExceptionAsync()
It.IsAny()))
.Throws(new InvalidOperationException("Streaming failed"));
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
var thread = agent.GetNewThread();
// Act & Assert - Verify that streaming throws an exception
@@ -688,7 +688,7 @@ static async IAsyncEnumerable GetUpdatesWithExceptionAsync()
It.IsAny()))
.Returns(GetUpdatesWithExceptionAsync());
- var agent = new ChatClientAgent(mockChatClient.Object, new());
+ var agent = new ChatClientAgent(mockChatClient.Object, options: new());
var thread = agent.GetNewThread();
// Act & Assert - Verify that streaming throws an exception after some updates
diff --git a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistant.IntegrationTests.csproj b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistant.IntegrationTests.csproj
index a7de0b858..f4d55d40f 100644
--- a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistant.IntegrationTests.csproj
+++ b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistant.IntegrationTests.csproj
@@ -4,6 +4,7 @@
$(ProjectsTargetFrameworks)
$(ProjectsDebugTargetFrameworks)
True
+ $(NoWarn);OPENAI001;
diff --git a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantFixture.cs b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantFixture.cs
index 250da1ce6..71f0de051 100644
--- a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantFixture.cs
+++ b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantFixture.cs
@@ -13,8 +13,6 @@
namespace OpenAIAssistant.IntegrationTests;
-#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
-
public class OpenAIAssistantFixture : IChatClientAgentFixture
{
private static readonly OpenAIConfiguration s_config = TestConfiguration.LoadSection();
@@ -67,7 +65,7 @@ public async Task CreateChatClientAgentAsync(
return new ChatClientAgent(
this._assistantClient.AsIChatClient(assistant.Value.Id),
- new()
+ options: new()
{
Id = assistant.Value.Id,
ChatOptions = new() { Tools = aiTools }
diff --git a/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs b/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs
index 7c54dc5b8..78c42ca93 100644
--- a/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs
+++ b/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs
@@ -50,7 +50,7 @@ public Task CreateChatClientAgentAsync(
.GetChatClient(this._useReasoningModel ? s_config.ChatReasoningModelId : s_config.ChatModelId)
.AsIChatClient();
- return Task.FromResult(new ChatClientAgent(chatClient, new()
+ return Task.FromResult(new ChatClientAgent(chatClient, options: new()
{
Name = name,
Instructions = instructions,
diff --git a/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponse.IntegrationTests.csproj b/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponse.IntegrationTests.csproj
index 0aabad91c..b45e0009d 100644
--- a/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponse.IntegrationTests.csproj
+++ b/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponse.IntegrationTests.csproj
@@ -4,6 +4,7 @@
$(ProjectsTargetFrameworks)
$(ProjectsDebugTargetFrameworks)
True
+ $(NoWarn);OPENAI001;
diff --git a/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs b/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs
index bce26d9e2..ec46c0197 100644
--- a/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs
+++ b/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs
@@ -12,8 +12,6 @@
using OpenAI.Responses;
using Shared.IntegrationTests;
-#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
-
namespace OpenAIResponse.IntegrationTests;
public class OpenAIResponseFixture(bool store) : IChatClientAgentFixture
@@ -80,7 +78,7 @@ public Task CreateChatClientAgentAsync(
{
return Task.FromResult(new ChatClientAgent(
this._openAIResponseClient.AsIChatClient(),
- new()
+ options: new()
{
Name = name,
Instructions = instructions,