diff --git a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/AssistantClientResultExtensions.cs b/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/AssistantClientResultExtensions.cs
deleted file mode 100644
index c92dda7105..0000000000
--- a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/AssistantClientResultExtensions.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using System.ClientModel;
-using Microsoft.Agents.AI;
-using Microsoft.Extensions.AI;
-
-namespace OpenAI.Assistants;
-
-///
-/// Provides extension methods for working with where T is .
-///
-public static class AssistantExtensions
-{
- ///
- /// Converts a to a .
- ///
- /// The client result containing the assistant.
- /// The assistant client.
- /// Optional chat options.
- /// Provides a way to customize the creation of the underlying used by the agent.
- /// A instance that can be used to perform operations on the assistant.
- public static ChatClientAgent AsAIAgent(
- this ClientResult assistantClientResult,
- AssistantClient assistantClient,
- ChatOptions? chatOptions = null,
- Func? clientFactory = null)
- {
- if (assistantClientResult is null)
- {
- throw new ArgumentNullException(nameof(assistantClientResult));
- }
-
- return AsAIAgent(assistantClientResult.Value, assistantClient, chatOptions, clientFactory);
- }
-
- ///
- /// Converts an to a .
- ///
- /// The assistant metadata.
- /// The assistant client.
- /// Optional chat options.
- /// Provides a way to customize the creation of the underlying used by the agent.
- /// A instance that can be used to perform operations on the assistant.
- public static ChatClientAgent AsAIAgent(
- this Assistant assistantMetadata,
- AssistantClient assistantClient,
- ChatOptions? chatOptions = null,
- Func? clientFactory = null)
- {
- if (assistantMetadata is null)
- {
- throw new ArgumentNullException(nameof(assistantMetadata));
- }
- if (assistantClient is null)
- {
- throw new ArgumentNullException(nameof(assistantClient));
- }
-
- var chatClient = assistantClient.AsIChatClient(assistantMetadata.Id);
-
- if (clientFactory is not null)
- {
- chatClient = clientFactory(chatClient);
- }
-
- return new ChatClientAgent(chatClient, options: new()
- {
- Id = assistantMetadata.Id,
- Name = assistantMetadata.Name,
- Description = assistantMetadata.Description,
- Instructions = assistantMetadata.Instructions,
- ChatOptions = chatOptions
- });
- }
-}
diff --git a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs b/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs
index 79c6e18165..7eb67f108c 100644
--- a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs
+++ b/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
+using System.ClientModel;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Logging;
@@ -20,6 +21,68 @@ namespace OpenAI;
///
public static class OpenAIAssistantClientExtensions
{
+ ///
+ /// Converts a to a .
+ ///
+ /// The assistant client.
+ /// The client result containing the assistant.
+ /// Optional chat options.
+ /// Provides a way to customize the creation of the underlying used by the agent.
+ /// A instance that can be used to perform operations on the assistant.
+ public static ChatClientAgent AsAIAgent(
+ this AssistantClient assistantClient,
+ ClientResult assistantClientResult,
+ ChatOptions? chatOptions = null,
+ Func? clientFactory = null)
+ {
+ if (assistantClientResult is null)
+ {
+ throw new ArgumentNullException(nameof(assistantClientResult));
+ }
+
+ return assistantClient.AsAIAgent(assistantClientResult.Value, chatOptions, clientFactory);
+ }
+
+ ///
+ /// Converts an to a .
+ ///
+ /// The assistant client.
+ /// The assistant metadata.
+ /// Optional chat options.
+ /// Provides a way to customize the creation of the underlying used by the agent.
+ /// A instance that can be used to perform operations on the assistant.
+ public static ChatClientAgent AsAIAgent(
+ this AssistantClient assistantClient,
+ Assistant assistantMetadata,
+ ChatOptions? chatOptions = null,
+ Func? clientFactory = null)
+ {
+ if (assistantMetadata is null)
+ {
+ throw new ArgumentNullException(nameof(assistantMetadata));
+ }
+ if (assistantClient is null)
+ {
+ throw new ArgumentNullException(nameof(assistantClient));
+ }
+
+ var chatClient = assistantClient.AsIChatClient(assistantMetadata.Id);
+
+ if (clientFactory is not null)
+ {
+ chatClient = clientFactory(chatClient);
+ }
+
+ return new ChatClientAgent(chatClient, options: new()
+ {
+ Id = assistantMetadata.Id,
+ Name = assistantMetadata.Name,
+ Description = assistantMetadata.Description,
+ Instructions = assistantMetadata.Instructions,
+ ChatOptions = chatOptions
+ });
+ }
+
///
/// Retrieves an existing server side agent, wrapped as a using the provided .
///
@@ -47,7 +110,7 @@ public static class OpenAIAssistantClientExtensions
}
var assistant = assistantClient.GetAssistant(agentId, cancellationToken);
- return assistant.AsAIAgent(assistantClient, chatOptions, clientFactory);
+ return assistantClient.AsAIAgent(assistant, chatOptions, clientFactory);
}
///
@@ -76,9 +139,8 @@ public static class OpenAIAssistantClientExtensions
throw new ArgumentException($"{nameof(agentId)} should not be null or whitespace.", nameof(agentId));
}
- var assistanceResponse = await assistantClient.GetAssistantAsync(agentId, cancellationToken).ConfigureAwait(false);
-
- return assistanceResponse.AsAIAgent(assistantClient, chatOptions, clientFactory);
+ var assistantResponse = await assistantClient.GetAssistantAsync(agentId, cancellationToken).ConfigureAwait(false);
+ return assistantClient.AsAIAgent(assistantResponse, chatOptions, clientFactory);
}
///
diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs
index 8fc5153f03..d9c3863dd6 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs
@@ -159,7 +159,7 @@ public class AgentWorkflowBuilderTests
private sealed class DoubleEchoAgentThread() : InMemoryAgentThread();
- [Fact]
+ [Fact(Skip = "issue #1109")]
public async Task BuildConcurrent_AgentsRunInParallelAsync()
{
StrongBox> barrier = new();