Skip to content

A programming framework for agentic AI

add xml comments for AgentRuntimeExtensions.cs

Griffin Bassmand6a83a2f7cfb
diff --git a/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentRuntimeExtensions.cs b/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentRuntimeExtensions.cs
index 1461d9b70..542e3fc1c 100644
--- a/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentRuntimeExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Contracts/PythonEquiv/AgentRuntimeExtensions.cs
@@ -5,8 +5,18 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AutoGen.Contracts.Python;
+/// <summary>
+/// Provides extension methods for managing and registering agents within an <see cref="IAgentRuntime"/>.
+/// </summary>
public static class AgentRuntimeExtensions
{
+ /// <summary>
+ /// Instantiates and activates an agent asynchronously using dependency injection.
+ /// </summary>
+ /// <typeparam name="TAgent">The type of agent to activate. Must implement <see cref="IHostableAgent"/>.</typeparam>
+ /// <param name="serviceProvider">The service provider used for dependency injection.</param>
+ /// <param name="additionalArguments">Additional arguments to pass to the agent's constructor.</param>
+ /// <returns>A <see cref="ValueTask{T}"/> representing the asynchronous activation of the agent.</returns>
internal static ValueTask<TAgent> ActivateAgentAsync<TAgent>(IServiceProvider serviceProvider, params object[] additionalArguments) where TAgent : IHostableAgent
{
try
@@ -20,10 +30,18 @@ public static class AgentRuntimeExtensions
}
}
+ /// <summary>
+ /// Registers an agent type with the runtime, providing a factory function to create instances of the agent.
+ /// </summary>
+ /// <typeparam name="TAgent">The type of agent being registered. Must implement <see cref="IHostableAgent"/>.</typeparam>
+ /// <param name="runtime">The <see cref="IAgentRuntime"/> where the agent will be registered.</param>
+ /// <param name="type">The <see cref="AgentType"/> representing the type of agent.</param>
+ /// <param name="serviceProvider">The service provider used for dependency injection.</param>
+ /// <param name="additionalArguments">Additional arguments to pass to the agent's constructor.</param>
+ /// <returns>A <see cref="ValueTask{AgentType}"/> representing the asynchronous operation of registering the agent.</returns>
public static ValueTask<AgentType> RegisterAgentTypeAsync<TAgent>(this IAgentRuntime runtime, AgentType type, IServiceProvider serviceProvider, params object[] additionalArguments) where TAgent : IHostableAgent
{
Func<ValueTask<TAgent>> factory = () => ActivateAgentAsync<TAgent>(serviceProvider, additionalArguments);
return runtime.RegisterAgentFactoryAsync(type, factory);
}
}
-