diff --git a/dotnet/src/Microsoft.Agents.AI.AzureAI/PersistentAgentResponseExtensions.cs b/dotnet/src/Microsoft.Agents.AI.AzureAI/PersistentAgentResponseExtensions.cs
deleted file mode 100644
index 62eee83529..0000000000
--- a/dotnet/src/Microsoft.Agents.AI.AzureAI/PersistentAgentResponseExtensions.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-
-using Microsoft.Agents.AI;
-using Microsoft.Extensions.AI;
-
-namespace Azure.AI.Agents.Persistent;
-
-///
-/// Provides extension methods for working with .
-///
-internal static class PersistentAgentResponseExtensions
-{
- ///
- /// Converts a response containing persistent agent metadata into a runnable agent instance.
- ///
- /// The response containing the persistent agent to be converted. Cannot be .
- /// The client used to interact with persistent agents. Cannot be .
- /// The default to use when interacting with the agent.
- /// 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 persistent agent.
- public static ChatClientAgent AsAIAgent(this Response persistentAgentResponse, PersistentAgentsClient persistentAgentsClient, ChatOptions? chatOptions = null, Func? clientFactory = null)
- {
- if (persistentAgentResponse is null)
- {
- throw new ArgumentNullException(nameof(persistentAgentResponse));
- }
-
- return AsAIAgent(persistentAgentResponse.Value, persistentAgentsClient, chatOptions, clientFactory);
- }
-
- ///
- /// Converts a containing metadata about a persistent agent into a runnable agent instance.
- ///
- /// The persistent agent metadata to be converted. Cannot be .
- /// The client used to interact with persistent agents. Cannot be .
- /// The default to use when interacting with the agent.
- /// 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 persistent agent.
- public static ChatClientAgent AsAIAgent(this PersistentAgent persistentAgentMetadata, PersistentAgentsClient persistentAgentsClient, ChatOptions? chatOptions = null, Func? clientFactory = null)
- {
- if (persistentAgentMetadata is null)
- {
- throw new ArgumentNullException(nameof(persistentAgentMetadata));
- }
-
- if (persistentAgentsClient is null)
- {
- throw new ArgumentNullException(nameof(persistentAgentsClient));
- }
-
- var chatClient = persistentAgentsClient.AsIChatClient(persistentAgentMetadata.Id);
-
- if (clientFactory is not null)
- {
- chatClient = clientFactory(chatClient);
- }
-
- return new ChatClientAgent(chatClient, options: new()
- {
- Id = persistentAgentMetadata.Id,
- Name = persistentAgentMetadata.Name,
- Description = persistentAgentMetadata.Description,
- Instructions = persistentAgentMetadata.Instructions,
- ChatOptions = chatOptions
- });
- }
-}
diff --git a/dotnet/src/Microsoft.Agents.AI.AzureAI/PersistentAgentsClientExtensions.cs b/dotnet/src/Microsoft.Agents.AI.AzureAI/PersistentAgentsClientExtensions.cs
index 1772b13991..72c77a94a4 100644
--- a/dotnet/src/Microsoft.Agents.AI.AzureAI/PersistentAgentsClientExtensions.cs
+++ b/dotnet/src/Microsoft.Agents.AI.AzureAI/PersistentAgentsClientExtensions.cs
@@ -10,6 +10,61 @@ namespace Azure.AI.Agents.Persistent;
///
public static class PersistentAgentsClientExtensions
{
+ ///
+ /// Gets a runnable agent instance from the provided response containing persistent agent metadata.
+ ///
+ /// The client used to interact with persistent agents. Cannot be .
+ /// The response containing the persistent agent to be converted. Cannot be .
+ /// The default to use when interacting with the agent.
+ /// 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 persistent agent.
+ public static ChatClientAgent GetAIAgent(this PersistentAgentsClient persistentAgentsClient, Response persistentAgentResponse, ChatOptions? chatOptions = null, Func? clientFactory = null)
+ {
+ if (persistentAgentResponse is null)
+ {
+ throw new ArgumentNullException(nameof(persistentAgentResponse));
+ }
+
+ return GetAIAgent(persistentAgentsClient, persistentAgentResponse.Value, chatOptions, clientFactory);
+ }
+
+ ///
+ /// Gets a runnable agent instance from a containing metadata about a persistent agent.
+ ///
+ /// The client used to interact with persistent agents. Cannot be .
+ /// The persistent agent metadata to be converted. Cannot be .
+ /// The default to use when interacting with the agent.
+ /// 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 persistent agent.
+ public static ChatClientAgent GetAIAgent(this PersistentAgentsClient persistentAgentsClient, PersistentAgent persistentAgentMetadata, ChatOptions? chatOptions = null, Func? clientFactory = null)
+ {
+ if (persistentAgentMetadata is null)
+ {
+ throw new ArgumentNullException(nameof(persistentAgentMetadata));
+ }
+
+ if (persistentAgentsClient is null)
+ {
+ throw new ArgumentNullException(nameof(persistentAgentsClient));
+ }
+
+ var chatClient = persistentAgentsClient.AsIChatClient(persistentAgentMetadata.Id);
+
+ if (clientFactory is not null)
+ {
+ chatClient = clientFactory(chatClient);
+ }
+
+ return new ChatClientAgent(chatClient, options: new()
+ {
+ Id = persistentAgentMetadata.Id,
+ Name = persistentAgentMetadata.Name,
+ Description = persistentAgentMetadata.Description,
+ Instructions = persistentAgentMetadata.Instructions,
+ ChatOptions = chatOptions
+ });
+ }
+
///
/// Retrieves an existing server side agent, wrapped as a using the provided .
///
@@ -38,7 +93,7 @@ public static class PersistentAgentsClientExtensions
}
var persistentAgentResponse = persistentAgentsClient.Administration.GetAgent(agentId, cancellationToken);
- return persistentAgentResponse.AsAIAgent(persistentAgentsClient, chatOptions, clientFactory);
+ return persistentAgentsClient.GetAIAgent(persistentAgentResponse, chatOptions, clientFactory);
}
///
@@ -69,7 +124,7 @@ public static class PersistentAgentsClientExtensions
}
var persistentAgentResponse = await persistentAgentsClient.Administration.GetAgentAsync(agentId, cancellationToken).ConfigureAwait(false);
- return persistentAgentResponse.AsAIAgent(persistentAgentsClient, chatOptions, clientFactory);
+ return persistentAgentsClient.GetAIAgent(persistentAgentResponse, chatOptions, clientFactory);
}
///
diff --git a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs b/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs
index d71796c3bb..94410bb7d0 100644
--- a/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs
+++ b/dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs
@@ -22,14 +22,14 @@ namespace OpenAI;
public static class OpenAIAssistantClientExtensions
{
///
- /// Converts a to a .
+ /// Gets a from 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(
+ public static ChatClientAgent GetAIAgent(
this AssistantClient assistantClient,
ClientResult assistantClientResult,
ChatOptions? chatOptions = null,
@@ -40,18 +40,18 @@ public static class OpenAIAssistantClientExtensions
throw new ArgumentNullException(nameof(assistantClientResult));
}
- return assistantClient.AsAIAgent(assistantClientResult.Value, chatOptions, clientFactory);
+ return assistantClient.GetAIAgent(assistantClientResult.Value, chatOptions, clientFactory);
}
///
- /// Converts an to a .
+ /// Gets a from an .
///
/// 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(
+ public static ChatClientAgent GetAIAgent(
this AssistantClient assistantClient,
Assistant assistantMetadata,
ChatOptions? chatOptions = null,
@@ -110,7 +110,7 @@ public static class OpenAIAssistantClientExtensions
}
var assistant = assistantClient.GetAssistant(agentId, cancellationToken);
- return assistantClient.AsAIAgent(assistant, chatOptions, clientFactory);
+ return assistantClient.GetAIAgent(assistant, chatOptions, clientFactory);
}
///
@@ -140,7 +140,7 @@ public static class OpenAIAssistantClientExtensions
}
var assistantResponse = await assistantClient.GetAssistantAsync(agentId, cancellationToken).ConfigureAwait(false);
- return assistantClient.AsAIAgent(assistantResponse, chatOptions, clientFactory);
+ return assistantClient.GetAIAgent(assistantResponse, chatOptions, clientFactory);
}
///
diff --git a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/Extensions/PersistentAgentsClientExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/Extensions/PersistentAgentsClientExtensionsTests.cs
index 7e252c84ae..705136ba0e 100644
--- a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/Extensions/PersistentAgentsClientExtensionsTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/Extensions/PersistentAgentsClientExtensionsTests.cs
@@ -41,7 +41,7 @@ public sealed class PersistentAgentsClientExtensionsTests
// Act & Assert - null agentId
var exception1 = Assert.Throws(() =>
- mockClient.Object.GetAIAgent(null!));
+ mockClient.Object.GetAIAgent((string)null!));
Assert.Equal("agentId", exception1.ParamName);
// Act & Assert - empty agentId